From 8a05aeaaa7b04ca42d56abd35ed30e3b88908d94 Mon Sep 17 00:00:00 2001 From: Victor Tran Date: Thu, 14 Sep 2023 20:19:58 +1000 Subject: [PATCH] Add touch bar on main window --- application/mainwindow.cpp | 21 ++++++++++++ application/mainwindow.ui | 6 ++++ application/translations/en_US.ts | 54 +++++++++++++++++++++++++++---- application/translations/vi_VN.ts | 54 +++++++++++++++++++++++++++---- 4 files changed, 123 insertions(+), 12 deletions(-) diff --git a/application/mainwindow.cpp b/application/mainwindow.cpp index 4a58d46..3767c7f 100644 --- a/application/mainwindow.cpp +++ b/application/mainwindow.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -43,6 +45,8 @@ struct MainWindowPrivate { tCommandPaletteDocumentSpecificScope* branchesScope; QMap tabButtons; + + tTouchBar* touchBar; }; MainWindow::MainWindow(QWidget* parent) : @@ -147,6 +151,23 @@ MainWindow::MainWindow(QWidget* parent) : commandPaletteActionScope->addMenuBar(ui->menuBar); + d->touchBar = new tTouchBar(this); + d->touchBar->setCustomizationIdentifier(QStringLiteral("com.vicr123.thebranch")); + d->touchBar->addDefaultItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.commit"), ui->actionCommit, tr("Commit"), {}, this)); + d->touchBar->addDefaultItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.push"), ui->actionPush, "", {}, this)); + d->touchBar->addDefaultItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.pull"), ui->actionPull, "", {}, this)); + d->touchBar->addItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.checkout"), ui->actionCheckout, tr("Checkout"), {}, this)); + d->touchBar->addItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.merge"), ui->actionMerge, tr("Merge"), {}, this)); + d->touchBar->addItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.rebase"), ui->actionRebase, tr("Rebase"), {}, this)); + d->touchBar->addItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.cherrypick"), ui->actionCherry_Pick, tr("Cherry Pick"), {}, this)); + d->touchBar->addItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.revert"), ui->actionRevert, tr("Revert"), {}, this)); + d->touchBar->addItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.branch"), ui->actionNew_Branch, tr("New Branch"), {}, this)); + d->touchBar->addItem(new tTouchBarActionItem(QStringLiteral("com.vicr123.thebranch.tag"), ui->actionNew_Tag, tr("New Tag"), {}, this)); + + d->touchBar->attach(this); + + tTouchBar::addCustomizationMenuItem(ui->menuView); + updateMenuItems(); } diff --git a/application/mainwindow.ui b/application/mainwindow.ui index fde1c15..28d717c 100644 --- a/application/mainwindow.ui +++ b/application/mainwindow.ui @@ -156,10 +156,16 @@ + + + View + + + diff --git a/application/translations/en_US.ts b/application/translations/en_US.ts index fe90cea..f553b59 100644 --- a/application/translations/en_US.ts +++ b/application/translations/en_US.ts @@ -47,7 +47,7 @@ - + theBranch @@ -80,9 +80,15 @@ - + + + View + + + + - + Exit @@ -321,7 +327,7 @@ - + @@ -329,12 +335,48 @@ - + + Commit - + + Checkout + + + + + Merge + + + + + Rebase + + + + + Cherry Pick + + + + + Revert + + + + + New Branch + + + + + New Tag + + + + Git diff --git a/application/translations/vi_VN.ts b/application/translations/vi_VN.ts index b64c071..2fe4e3e 100644 --- a/application/translations/vi_VN.ts +++ b/application/translations/vi_VN.ts @@ -47,7 +47,7 @@ - + theBranch theBranch @@ -80,9 +80,15 @@ Cây - + + + View + + + + - + Exit Thoát @@ -321,7 +327,7 @@ - + @@ -329,12 +335,48 @@ - + + Commit Chuyển giao - + + Checkout + + + + + Merge + + + + + Rebase + + + + + Cherry Pick + + + + + Revert + + + + + New Branch + + + + + New Tag + + + + Git Git