diff --git a/.gitmodules b/.gitmodules index 4053728..d92df61 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "contrib/tor"] path = contrib/tor url = https://git.torproject.org/tor.git +[submodule "contrib/KDMacTouchBar"] + path = contrib/KDMacTouchBar + url = https://github.com/KDAB/KDMacTouchBar.git diff --git a/CMakeLists.txt b/CMakeLists.txt index fbd7128..acee3ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -365,4 +365,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 ${C_SECURITY_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${CXX_SECURITY_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LD_SECURITY_FLAGS} ${STATIC_FLAGS}") +if(APPLE) + add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/contrib/KDMacTouchBar") +endif() + add_subdirectory(src) diff --git a/contrib/KDMacTouchBar b/contrib/KDMacTouchBar new file mode 160000 index 0000000..470c431 --- /dev/null +++ b/contrib/KDMacTouchBar @@ -0,0 +1 @@ +Subproject commit 470c4316460bb8c3e23bfa37c79c8621ef3f1b4c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da2f614..1ac2797 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -201,6 +201,14 @@ target_link_libraries(feather ${QRENCODE_LIBRARY} ) +if(APPLE) + target_link_libraries(feather + KDMacTouchBar + ) + target_include_directories(feather + PUBLIC ../contrib/KDMacTouchBar) +endif() + if(NOT APPLE) target_link_libraries(feather Qt5::QSvgIconPlugin diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 66ae668..4878f1c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -351,6 +351,14 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) : // window title connect(m_ctx, &AppContext::setTitle, this, &QMainWindow::setWindowTitle); + // init touchbar +#ifdef Q_OS_MAC + m_touchbar = new KDMacTouchBar(this); + m_touchbarActionWelcome = new QAction(QIcon(":/assets/images/feather.png"), "Welcome to Feather!"); + m_touchbarWalletItems = {ui->actionSettings, ui->actionCalculator, ui->actionKeys, ui->actionDonate_to_Feather}; + m_touchbarWizardItems = {m_touchbarActionWelcome}; +#endif + // setup some UI this->initMain(); this->initWidgets(); @@ -382,6 +390,7 @@ void MainWindow::initMain() { this->show(); m_wizard = this->createWizard(WalletWizard::Page_Menu); m_wizard->show(); + this->touchbarShowWizard(); } void MainWindow::initMenu() { @@ -545,6 +554,20 @@ void MainWindow::onWalletClosed(WalletWizard::Page page) { this->showWizard(page); } +void MainWindow::touchbarShowWizard() { +#ifdef Q_OS_MAC + m_touchbar->clear(); + for(auto* action: m_touchbarWizardItems) m_touchbar->addAction(action); +#endif +} + +void MainWindow::touchbarShowWallet() { +#ifdef Q_OS_MAC + m_touchbar->clear(); + for(auto* action: m_touchbarWalletItems) m_touchbar->addAction(action); +#endif +} + void MainWindow::onWalletCreatedError(const QString &err) { Utils::showMessageBox("Wallet creation error", err, true); this->showWizard(WalletWizard::Page_CreateWallet); @@ -571,6 +594,7 @@ void MainWindow::onWalletOpenedError(const QString &err) { QMessageBox::warning(this, "Wallet open error", err); this->setWindowTitle("Feather"); this->showWizard(WalletWizard::Page_OpenWallet); + this->touchbarShowWizard(); } void MainWindow::onWalletCreated(Wallet *wallet) { @@ -630,6 +654,8 @@ void MainWindow::onWalletOpened() { connect(m_ctx->currentWallet->coins(), &Coins::coinThawed, [this]{ m_ctx->storeWallet(); }); + + this->touchbarShowWallet(); } void MainWindow::onBalanceUpdated(double balance, double unlocked, const QString &balance_str, const QString &unlocked_str) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 02bf8dc..baccc6e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -4,6 +4,10 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#ifdef Q_OS_MAC +#include "src/kdmactouchbar.h" +#endif + #include #include #include @@ -154,6 +158,8 @@ private: void showNodeExhaustedMessage(); void showWSNodeExhaustedMessage(); void createUnsignedTxDialog(UnsignedTransaction *tx); + void touchbarShowWizard(); + void touchbarShowWallet(); WalletWizard *createWizard(WalletWizard::Page startPage); @@ -192,7 +198,12 @@ private: SubaddressProxyModel *subaddressProxyModel; TransactionHistoryModel *txHistModel; CoinsModel *coinsModel; - +#ifdef Q_OS_MAC + QAction *m_touchbarActionWelcome; + KDMacTouchBar *m_touchbar; + QList m_touchbarWalletItems; + QList m_touchbarWizardItems; +#endif QSignalMapper *m_tabShowHideSignalMapper; QMap m_tabShowHideMapper; WalletWizard *m_wizard = nullptr;