Skip to content

Commit 6b2ce65

Browse files
committed
qt: Replace base class of ClickableLabel with ThemedLabel
This change fixes the GUI when changing appearance on macOS.
1 parent ff530a2 commit 6b2ce65

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/qt/bitcoingui.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
152152
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
153153
labelWalletEncryptionIcon = new GUIUtil::ThemedLabel(platformStyle);
154154
labelWalletHDStatusIcon = new GUIUtil::ThemedLabel(platformStyle);
155-
labelProxyIcon = new GUIUtil::ClickableLabel();
156-
connectionsControl = new GUIUtil::ClickableLabel();
157-
labelBlocksIcon = new GUIUtil::ClickableLabel();
155+
labelProxyIcon = new GUIUtil::ClickableLabel(platformStyle);
156+
connectionsControl = new GUIUtil::ClickableLabel(platformStyle);
157+
labelBlocksIcon = new GUIUtil::ClickableLabel(platformStyle);
158158
if(enableWallet)
159159
{
160160
frameBlocksLayout->addStretch();
@@ -925,7 +925,7 @@ void BitcoinGUI::updateNetworkState()
925925
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
926926
connectionsControl->setToolTip(tooltip);
927927

928-
connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
928+
connectionsControl->setThemedPixmap(icon, STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
929929
}
930930

931931
void BitcoinGUI::setNumConnections(int count)
@@ -1021,7 +1021,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
10211021
// Set icon state: spinning if catching up, tick otherwise
10221022
if (secs < MAX_BLOCK_TIME_GAP) {
10231023
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
1024-
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1024+
labelBlocksIcon->setThemedPixmap(QStringLiteral(":/icons/synced"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
10251025

10261026
#ifdef ENABLE_WALLET
10271027
if(walletFrame)
@@ -1047,9 +1047,9 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
10471047
tooltip = tr("Catching up...") + QString("<br>") + tooltip;
10481048
if(count != prevBlocks)
10491049
{
1050-
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
1051-
":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
1052-
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1050+
labelBlocksIcon->setThemedPixmap(
1051+
QString(":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')),
1052+
STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
10531053
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
10541054
}
10551055
prevBlocks = count;
@@ -1325,7 +1325,7 @@ void BitcoinGUI::updateProxyIcon()
13251325
if (proxy_enabled) {
13261326
if (!GUIUtil::HasPixmap(labelProxyIcon)) {
13271327
QString ip_port_q = QString::fromStdString(ip_port);
1328-
labelProxyIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/proxy").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1328+
labelProxyIcon->setThemedPixmap((":/icons/proxy"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
13291329
labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
13301330
} else {
13311331
labelProxyIcon->show();

src/qt/guiutil.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,11 @@ void ThemedLabel::updateThemedPixmap()
817817
setPixmap(m_platform_style->SingleColorIcon(m_image_filename).pixmap(m_pixmap_width, m_pixmap_height));
818818
}
819819

820+
ClickableLabel::ClickableLabel(const PlatformStyle* platform_style, QWidget* parent)
821+
: ThemedLabel{platform_style, parent}
822+
{
823+
}
824+
820825
void ClickableLabel::mouseReleaseEvent(QMouseEvent *event)
821826
{
822827
Q_EMIT clicked(event->pos());

src/qt/guiutil.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,13 @@ namespace GUIUtil
241241
void updateThemedPixmap();
242242
};
243243

244-
class ClickableLabel : public QLabel
244+
class ClickableLabel : public ThemedLabel
245245
{
246246
Q_OBJECT
247247

248+
public:
249+
explicit ClickableLabel(const PlatformStyle* platform_style, QWidget* parent = nullptr);
250+
248251
Q_SIGNALS:
249252
/** Emitted when the label is clicked. The relative mouse coordinates of the click are
250253
* passed to the signal.

0 commit comments

Comments
 (0)