aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-05-28 18:04:50 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-05-28 18:07:44 +0300
commit123b401e0acf3b26f149711bdf06d7f6eced1968 (patch)
tree332489bb57cfd42aa4254858ab786d7cf03394f1 /src/qt/bitcoingui.cpp
parent8115c2ad7dc87cc37662421875b728ffc29aaffd (diff)
parentc231254a65d390a3350fcef456d57e4a6eca0506 (diff)
downloadbitcoin-123b401e0acf3b26f149711bdf06d7f6eced1968.tar.xz
Merge bitcoin-core/gui#275: Support runtime appearance adjustment on macOS
c231254a65d390a3350fcef456d57e4a6eca0506 qt: Make TransactionView aware of runtime palette change (Hennadii Stepanov) 2b622d4aced1848393989ee906b1f9d2436f1c1a qt: Make CoinControlDialog aware of runtime palette change (Hennadii Stepanov) 97a6b5e06a532a4ee029c8ba59c3438369f8b049 qt: Make OverviewPage aware of runtime palette change (Hennadii Stepanov) d05f1b278d9846de5142a4ac3f53c84145330dd1 qt: Make UnitDisplayStatusBarControl aware of runtime palette change (Hennadii Stepanov) 6b2ce65392dc98250e84941370e975048b8afc54 qt: Replace base class of ClickableLabel with ThemedLabel (Hennadii Stepanov) ff530a2093c294a1093e1b00fb66ab0a98851c04 qt: Use GUIUtil::ThemedLabel class (Hennadii Stepanov) d99ef327a885874fed1c4e35e0f47b10290c6bd9 qt: Add GUIUtil::ThemedLabel class (Hennadii Stepanov) c054720e08b5549913f54b9b4bc4e4002617ff23 qt: Make SignVerifyMessageDialog aware of runtime palette change (Hennadii Stepanov) 0dcc3fac433b341eb6e1d3a2fb4d2de1595e8e88 qt: Make SendCoinsEntry aware of runtime palette change (Hennadii Stepanov) fa18d28e1242c2948814df1082ee12c2fecf5403 qt: Make RPCConsole aware of runtime palette change (Hennadii Stepanov) f1083826e3e68803da86af6efba21c4080769b5c qt: Make BitcoinGUI aware of runtime palette change (Hennadii Stepanov) ce17861dc419b0d1fc1d933000f484dd08bacf5b qt: Make PlatformStyle aware of runtime palette change (Hennadii Stepanov) Pull request description: On macOS switching appearance (Light -> Dark or Dark -> Light) when Bitcoin Core is running makes the GUI pretty unusable. This bug is especially important when a user chose the "Auto" mode to adjust appearance automatically. This PR fixes Bitcoin Core behavior. This is an alternative to #268. ACKs for top commit: Sjors: tACK c231254a65d390a3350fcef456d57e4a6eca0506 on macOS 11.4 goums: ACK c231254a65d390a3350fcef456d57e4a6eca0506 promag: Tested ACK c231254a65d390a3350fcef456d57e4a6eca0506 on macOS Big Sur arm64. jarolrod: tACK c231254a65d390a3350fcef456d57e4a6eca0506 Tree-SHA512: 122dda3e4c9703f68cec60613c536ca59d04c93f2c03398559f2361b8d279ae534800e8e677d94a33e10e769d00be54295a704e98afa2e986a06146b9f164854
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp59
1 files changed, 41 insertions, 18 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 17fffe2087..858010a38c 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -150,11 +150,11 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3);
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
- labelWalletEncryptionIcon = new QLabel();
- labelWalletHDStatusIcon = new QLabel();
- labelProxyIcon = new GUIUtil::ClickableLabel();
- connectionsControl = new GUIUtil::ClickableLabel();
- labelBlocksIcon = new GUIUtil::ClickableLabel();
+ labelWalletEncryptionIcon = new GUIUtil::ThemedLabel(platformStyle);
+ labelWalletHDStatusIcon = new GUIUtil::ThemedLabel(platformStyle);
+ labelProxyIcon = new GUIUtil::ClickableLabel(platformStyle);
+ connectionsControl = new GUIUtil::ClickableLabel(platformStyle);
+ labelBlocksIcon = new GUIUtil::ClickableLabel(platformStyle);
if(enableWallet)
{
frameBlocksLayout->addStretch();
@@ -925,7 +925,7 @@ void BitcoinGUI::updateNetworkState()
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
connectionsControl->setToolTip(tooltip);
- connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
+ connectionsControl->setThemedPixmap(icon, STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
}
void BitcoinGUI::setNumConnections(int count)
@@ -1021,7 +1021,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
// Set icon state: spinning if catching up, tick otherwise
if (secs < MAX_BLOCK_TIME_GAP) {
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
- labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
+ labelBlocksIcon->setThemedPixmap(QStringLiteral(":/icons/synced"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
#ifdef ENABLE_WALLET
if(walletFrame)
@@ -1047,9 +1047,9 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
tooltip = tr("Catching up…") + QString("<br>") + tooltip;
if(count != prevBlocks)
{
- labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
- ":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
- .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
+ labelBlocksIcon->setThemedPixmap(
+ QString(":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')),
+ STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
}
prevBlocks = count;
@@ -1138,7 +1138,17 @@ void BitcoinGUI::message(const QString& title, QString message, unsigned int sty
void BitcoinGUI::changeEvent(QEvent *e)
{
+#ifdef Q_OS_MACOS
+ if (e->type() == QEvent::PaletteChange) {
+ overviewAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/overview")));
+ sendCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/send")));
+ receiveCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/receiving_addresses")));
+ historyAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/history")));
+ }
+#endif
+
QMainWindow::changeEvent(e);
+
#ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange)
{
@@ -1256,7 +1266,7 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
void BitcoinGUI::setHDStatus(bool privkeyDisabled, int hdEnabled)
{
- labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(privkeyDisabled ? ":/icons/eye" : hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
+ labelWalletHDStatusIcon->setThemedPixmap(privkeyDisabled ? QStringLiteral(":/icons/eye") : hdEnabled ? QStringLiteral(":/icons/hd_enabled") : QStringLiteral(":/icons/hd_disabled"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
labelWalletHDStatusIcon->setToolTip(privkeyDisabled ? tr("Private key <b>disabled</b>") : hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
labelWalletHDStatusIcon->show();
// eventually disable the QLabel to set its opacity to 50%
@@ -1275,7 +1285,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
break;
case WalletModel::Unlocked:
labelWalletEncryptionIcon->show();
- labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
+ labelWalletEncryptionIcon->setThemedPixmap(QStringLiteral(":/icons/lock_open"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
@@ -1283,7 +1293,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
break;
case WalletModel::Locked:
labelWalletEncryptionIcon->show();
- labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
+ labelWalletEncryptionIcon->setThemedPixmap(QStringLiteral(":/icons/lock_closed"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
@@ -1315,7 +1325,7 @@ void BitcoinGUI::updateProxyIcon()
if (proxy_enabled) {
if (!GUIUtil::HasPixmap(labelProxyIcon)) {
QString ip_port_q = QString::fromStdString(ip_port);
- labelProxyIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/proxy").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
+ labelProxyIcon->setThemedPixmap((":/icons/proxy"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
} else {
labelProxyIcon->show();
@@ -1440,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."));
@@ -1455,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 */
@@ -1464,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()
{