aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-04-08 19:56:16 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-05-01 15:07:11 +0300
commitd05f1b278d9846de5142a4ac3f53c84145330dd1 (patch)
tree710e4effad24f09b282e49baf56ae06fb12c2156 /src
parent6b2ce65392dc98250e84941370e975048b8afc54 (diff)
qt: Make UnitDisplayStatusBarControl aware of runtime palette change
This change fixes the GUI when changing appearance on macOS.
Diffstat (limited to 'src')
-rw-r--r--src/qt/bitcoingui.cpp21
-rw-r--r--src/qt/bitcoingui.h2
2 files changed, 19 insertions, 4 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index ff5d38fb0a..ae4db9fa80 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -1450,9 +1450,10 @@ bool BitcoinGUI::isPrivacyModeActivated() const
return m_mask_values_action->isChecked();
}
-UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
- optionsModel(nullptr),
- menu(nullptr)
+UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
+ : optionsModel(nullptr),
+ menu(nullptr),
+ m_platform_style{platformStyle}
{
createContextMenu();
setToolTip(tr("Unit to show amounts in. Click to select another unit."));
@@ -1465,7 +1466,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *pl
}
setMinimumSize(max_width, 0);
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
- setStyleSheet(QString("QLabel { color : %1 }").arg(platformStyle->SingleColor().name()));
+ setStyleSheet(QString("QLabel { color : %1 }").arg(m_platform_style->SingleColor().name()));
}
/** So that it responds to button clicks */
@@ -1474,6 +1475,18 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
onDisplayUnitsClicked(event->pos());
}
+void UnitDisplayStatusBarControl::changeEvent(QEvent* e)
+{
+#ifdef Q_OS_MACOS
+ if (e->type() == QEvent::PaletteChange) {
+ QString style = QString("QLabel { color : %1 }").arg(m_platform_style->SingleColor().name());
+ if (style != styleSheet()) {
+ setStyleSheet(style);
+ }
+ }
+#endif
+}
+
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
void UnitDisplayStatusBarControl::createContextMenu()
{
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index d1cfa547bd..65c5331d32 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -334,10 +334,12 @@ public:
protected:
/** So that it responds to left-button clicks */
void mousePressEvent(QMouseEvent *event) override;
+ void changeEvent(QEvent* e) override;
private:
OptionsModel *optionsModel;
QMenu* menu;
+ const PlatformStyle* m_platform_style;
/** Shows context menu with Display Unit options by the mouse coordinates */
void onDisplayUnitsClicked(const QPoint& point);