mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 11:39:25 +00:00
MacOS: add touchbar support
Co-Authored-By: dsc <dsc@xmr.pm>
This commit is contained in:
parent
34a63897d6
commit
e657e2a6b0
6 changed files with 54 additions and 1 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
1
contrib/KDMacTouchBar
Submodule
1
contrib/KDMacTouchBar
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 470c4316460bb8c3e23bfa37c79c8621ef3f1b4c
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "src/kdmactouchbar.h"
|
||||
#endif
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QScreen>
|
||||
|
@ -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<QAction *> m_touchbarWalletItems;
|
||||
QList<QAction *> m_touchbarWizardItems;
|
||||
#endif
|
||||
QSignalMapper *m_tabShowHideSignalMapper;
|
||||
QMap<QString, ToggleTab*> m_tabShowHideMapper;
|
||||
WalletWizard *m_wizard = nullptr;
|
||||
|
|
Loading…
Reference in a new issue