From c231254a65d390a3350fcef456d57e4a6eca0506 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 9 Apr 2021 08:28:03 +0300 Subject: [PATCH] qt: Make TransactionView aware of runtime palette change This change fixes the GUI when changing appearance on macOS. --- src/qt/transactionview.cpp | 18 ++++++++++++++++-- src/qt/transactionview.h | 5 +++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 890d1a1740f..6c8819b5493 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -37,8 +37,8 @@ #include #include -TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) : - QWidget(parent) +TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) + : QWidget(parent), m_platform_style{platformStyle} { // Build filter row setContentsMargins(0,0,0,0); @@ -243,6 +243,20 @@ void TransactionView::setModel(WalletModel *_model) } } +void TransactionView::changeEvent(QEvent* e) +{ +#ifdef Q_OS_MACOS + if (e->type() == QEvent::PaletteChange) { + watchOnlyWidget->setItemIcon( + TransactionFilterProxy::WatchOnlyFilter_Yes, + m_platform_style->SingleColorIcon(QStringLiteral(":/icons/eye_plus"))); + watchOnlyWidget->setItemIcon( + TransactionFilterProxy::WatchOnlyFilter_No, + m_platform_style->SingleColorIcon(QStringLiteral(":/icons/eye_minus"))); + } +#endif +} + void TransactionView::chooseDate(int idx) { if (!transactionProxyModel) return; diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 66350bdc02e..3e2321d91bc 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -60,6 +60,9 @@ public: MINIMUM_COLUMN_WIDTH = 23 }; +protected: + void changeEvent(QEvent* e) override; + private: WalletModel *model{nullptr}; TransactionFilterProxy *transactionProxyModel{nullptr}; @@ -85,6 +88,8 @@ private: bool eventFilter(QObject *obj, QEvent *event) override; + const PlatformStyle* m_platform_style; + private Q_SLOTS: void contextualMenu(const QPoint &); void dateRangeChanged();