From 97a6b5e06a532a4ee029c8ba59c3438369f8b049 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 8 Apr 2021 20:42:03 +0300 Subject: qt: Make OverviewPage aware of runtime palette change This change fixes the GUI when changing appearance on macOS. --- src/qt/overviewpage.cpp | 15 ++++++++++++++- src/qt/overviewpage.h | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 7f12b1d2b5..27783bdf87 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -78,6 +78,7 @@ public: { QIcon iconWatchonly = qvariant_cast(index.data(TransactionTableModel::WatchonlyDecorationRole)); QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight); + iconWatchonly = platformStyle->TextColorIcon(iconWatchonly); iconWatchonly.paint(painter, watchonlyRect); address_rect_min_width += 5 + watchonlyRect.width(); } @@ -143,6 +144,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui(new Ui::OverviewPage), clientModel(nullptr), walletModel(nullptr), + m_platform_style{platformStyle}, txdelegate(new TxViewDelegate(platformStyle, this)) { ui->setupUi(this); @@ -150,7 +152,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) m_balances.balance = -1; // use a SingleColorIcon for the "out of sync warning" icon - QIcon icon = platformStyle->SingleColorIcon(":/icons/warning"); + QIcon icon = m_platform_style->SingleColorIcon(QStringLiteral(":/icons/warning")); ui->labelTransactionsStatus->setIcon(icon); ui->labelWalletStatus->setIcon(icon); @@ -298,6 +300,17 @@ void OverviewPage::setWalletModel(WalletModel *model) updateDisplayUnit(); } +void OverviewPage::changeEvent(QEvent* e) +{ +#ifdef Q_OS_MACOS + if (e->type() == QEvent::PaletteChange) { + QIcon icon = m_platform_style->SingleColorIcon(QStringLiteral(":/icons/warning")); + ui->labelTransactionsStatus->setIcon(icon); + ui->labelWalletStatus->setIcon(icon); + } +#endif +} + void OverviewPage::updateDisplayUnit() { if(walletModel && walletModel->getOptionsModel()) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 5158c81678..755a107a00 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -45,6 +45,9 @@ Q_SIGNALS: void transactionClicked(const QModelIndex &index); void outOfSyncWarningClicked(); +protected: + void changeEvent(QEvent* e) override; + private: Ui::OverviewPage *ui; ClientModel *clientModel; @@ -52,6 +55,8 @@ private: interfaces::WalletBalances m_balances; bool m_privacy{false}; + const PlatformStyle* m_platform_style; + TxViewDelegate *txdelegate; std::unique_ptr filter; -- cgit v1.2.3