Skip to content

Commit

Permalink
Add touch bar on main window
Browse files Browse the repository at this point in the history
  • Loading branch information
vicr123 committed Oct 12, 2023
1 parent bc490a9 commit 8a05aea
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 12 deletions.
21 changes: 21 additions & 0 deletions application/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <thelpmenu.h>
#include <tjobmanager.h>
#include <tmessagebox.h>
#include <touchbar/ttouchbar.h>
#include <touchbar/ttouchbaractionitem.h>
#include <tpopover.h>
#include <tsettingswindow/tsettingswindow.h>
#include <twindowtabberbutton.h>
Expand Down Expand Up @@ -43,6 +45,8 @@ struct MainWindowPrivate {

tCommandPaletteDocumentSpecificScope* branchesScope;
QMap<RepositoryBrowser*, tWindowTabberButton*> tabButtons;

tTouchBar* touchBar;
};

MainWindow::MainWindow(QWidget* parent) :
Expand Down Expand Up @@ -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();
}

Expand Down
6 changes: 6 additions & 0 deletions application/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,16 @@
<addaction name="separator"/>
<addaction name="actionDiscard_All_Changes"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
</property>
</widget>
<addaction name="menuFile"/>
<addaction name="menuRepository"/>
<addaction name="menuTree"/>
<addaction name="menuRemotes"/>
<addaction name="menuView"/>
</widget>
<action name="actionExit">
<property name="icon">
Expand Down
54 changes: 48 additions & 6 deletions application/translations/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<message>
<location filename="../mainwindow.ui" line="+14"/>
<location/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="+341"/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="+345"/>
<source>theBranch</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -80,9 +80,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+21"/>
<location line="+12"/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="+1"/>
<source>View</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+15"/>
<location/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="-73"/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="-74"/>
<source>Exit</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -321,20 +327,56 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="+120"/>
<location filename="../mainwindow.cpp" line="+124"/>
<location line="+3"/>
<location line="+3"/>
<location line="+4"/>
<source>Open in %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+53"/>
<location line="+22"/>
<location line="+48"/>
<source>Commit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+106"/>
<location line="-45"/>
<source>Checkout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>Merge</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>Rebase</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>Cherry Pick</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>Revert</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>New Branch</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>New Tag</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+145"/>
<source>Git</source>
<translation type="unfinished"></translation>
</message>
Expand Down
54 changes: 48 additions & 6 deletions application/translations/vi_VN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<message>
<location filename="../mainwindow.ui" line="+14"/>
<location/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="+341"/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="+345"/>
<source>theBranch</source>
<translation>theBranch</translation>
</message>
Expand Down Expand Up @@ -80,9 +80,15 @@
<translation>Cây</translation>
</message>
<message>
<location line="+21"/>
<location line="+12"/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="+1"/>
<source>View</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+15"/>
<location/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="-73"/>
<location filename="../../../build-theBranch-Desktop_ARM-Debug/application/thebranch_autogen/include/ui_mainwindow.h" line="-74"/>
<source>Exit</source>
<translation>Thoát</translation>
</message>
Expand Down Expand Up @@ -321,20 +327,56 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="+120"/>
<location filename="../mainwindow.cpp" line="+124"/>
<location line="+3"/>
<location line="+3"/>
<location line="+4"/>
<source>Open in %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+53"/>
<location line="+22"/>
<location line="+48"/>
<source>Commit</source>
<translation>Chuyển giao</translation>
</message>
<message>
<location line="+106"/>
<location line="-45"/>
<source>Checkout</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>Merge</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>Rebase</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>Cherry Pick</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>Revert</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>New Branch</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>New Tag</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+145"/>
<source>Git</source>
<translation>Git</translation>
</message>
Expand Down

0 comments on commit 8a05aea

Please sign in to comment.