diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-04-08 16:14:12 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-05-01 15:07:10 +0300 |
commit | 6b2ce65392dc98250e84941370e975048b8afc54 (patch) | |
tree | 073a4e34edf623383a9a7418df5d0933ba9df481 | |
parent | ff530a2093c294a1093e1b00fb66ab0a98851c04 (diff) | |
download | bitcoin-6b2ce65392dc98250e84941370e975048b8afc54.tar.xz |
qt: Replace base class of ClickableLabel with ThemedLabel
This change fixes the GUI when changing appearance on macOS.
-rw-r--r-- | src/qt/bitcoingui.cpp | 18 | ||||
-rw-r--r-- | src/qt/guiutil.cpp | 5 | ||||
-rw-r--r-- | src/qt/guiutil.h | 5 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 5c3f16aab0..ff5d38fb0a 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -152,9 +152,9 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle); labelWalletEncryptionIcon = new GUIUtil::ThemedLabel(platformStyle); labelWalletHDStatusIcon = new GUIUtil::ThemedLabel(platformStyle); - labelProxyIcon = new GUIUtil::ClickableLabel(); - connectionsControl = new GUIUtil::ClickableLabel(); - labelBlocksIcon = new GUIUtil::ClickableLabel(); + 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; @@ -1325,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(); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 3c4f3df89d..b738d13840 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -817,6 +817,11 @@ void ThemedLabel::updateThemedPixmap() setPixmap(m_platform_style->SingleColorIcon(m_image_filename).pixmap(m_pixmap_width, m_pixmap_height)); } +ClickableLabel::ClickableLabel(const PlatformStyle* platform_style, QWidget* parent) + : ThemedLabel{platform_style, parent} +{ +} + void ClickableLabel::mouseReleaseEvent(QMouseEvent *event) { Q_EMIT clicked(event->pos()); diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 31e7aa7335..d3d0ba64ca 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -241,10 +241,13 @@ namespace GUIUtil void updateThemedPixmap(); }; - class ClickableLabel : public QLabel + class ClickableLabel : public ThemedLabel { Q_OBJECT + public: + explicit ClickableLabel(const PlatformStyle* platform_style, QWidget* parent = nullptr); + Q_SIGNALS: /** Emitted when the label is clicked. The relative mouse coordinates of the click are * passed to the signal. |