Skip to content

Commit

Permalink
qt: Make TransactionView aware of runtime palette change
Browse files Browse the repository at this point in the history
This change fixes the GUI when changing appearance on macOS.
  • Loading branch information
hebasto committed Apr 9, 2021
1 parent cceb6e6 commit 5737301
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#include <QUrl>
#include <QVBoxLayout>

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);
Expand Down Expand Up @@ -264,6 +264,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;
Expand Down
5 changes: 5 additions & 0 deletions src/qt/transactionview.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class TransactionView : public QWidget
MINIMUM_COLUMN_WIDTH = 23
};

protected:
void changeEvent(QEvent* e) override;

private:
WalletModel *model{nullptr};
TransactionFilterProxy *transactionProxyModel{nullptr};
Expand All @@ -85,6 +88,8 @@ class TransactionView : public QWidget

bool eventFilter(QObject *obj, QEvent *event) override;

const PlatformStyle* m_platform_style;

private Q_SLOTS:
void contextualMenu(const QPoint &);
void dateRangeChanged();
Expand Down

0 comments on commit 5737301

Please sign in to comment.