mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-28 18:46:24 +02:00
qt: Make UnitDisplayStatusBarControl aware of runtime palette change
This change fixes the GUI when changing appearance on macOS.
This commit is contained in:
@@ -1450,9 +1450,10 @@ bool BitcoinGUI::isPrivacyModeActivated() const
|
|||||||
return m_mask_values_action->isChecked();
|
return m_mask_values_action->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
|
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
|
||||||
optionsModel(nullptr),
|
: optionsModel(nullptr),
|
||||||
menu(nullptr)
|
menu(nullptr),
|
||||||
|
m_platform_style{platformStyle}
|
||||||
{
|
{
|
||||||
createContextMenu();
|
createContextMenu();
|
||||||
setToolTip(tr("Unit to show amounts in. Click to select another unit."));
|
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);
|
setMinimumSize(max_width, 0);
|
||||||
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
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 */
|
/** So that it responds to button clicks */
|
||||||
@@ -1474,6 +1475,18 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
|
|||||||
onDisplayUnitsClicked(event->pos());
|
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. */
|
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
|
||||||
void UnitDisplayStatusBarControl::createContextMenu()
|
void UnitDisplayStatusBarControl::createContextMenu()
|
||||||
{
|
{
|
||||||
|
@@ -334,10 +334,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
/** So that it responds to left-button clicks */
|
/** So that it responds to left-button clicks */
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
void changeEvent(QEvent* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OptionsModel *optionsModel;
|
OptionsModel *optionsModel;
|
||||||
QMenu* menu;
|
QMenu* menu;
|
||||||
|
const PlatformStyle* m_platform_style;
|
||||||
|
|
||||||
/** Shows context menu with Display Unit options by the mouse coordinates */
|
/** Shows context menu with Display Unit options by the mouse coordinates */
|
||||||
void onDisplayUnitsClicked(const QPoint& point);
|
void onDisplayUnitsClicked(const QPoint& point);
|
||||||
|
Reference in New Issue
Block a user