qt: Replace base class of ClickableLabel with ThemedLabel

This change fixes the GUI when changing appearance on macOS.
This commit is contained in:
Hennadii Stepanov committed 2021-05-01 15:07:10 +03:00
1 parent ff530a2093
commit 6b2ce65392
3 files changed
+18 -10

No files matched your search

+9 -9
View File
@@ -152,9 +152,9 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle); unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
labelWalletEncryptionIcon = new GUIUtil::ThemedLabel(platformStyle); labelWalletEncryptionIcon = new GUIUtil::ThemedLabel(platformStyle);
labelWalletHDStatusIcon = new GUIUtil::ThemedLabel(platformStyle); labelWalletHDStatusIcon = new GUIUtil::ThemedLabel(platformStyle);
labelProxyIcon = new GUIUtil::ClickableLabel(); labelProxyIcon = new GUIUtil::ClickableLabel(platformStyle);
connectionsControl = new GUIUtil::ClickableLabel(); connectionsControl = new GUIUtil::ClickableLabel(platformStyle);
labelBlocksIcon = new GUIUtil::ClickableLabel(); labelBlocksIcon = new GUIUtil::ClickableLabel(platformStyle);
if(enableWallet) if(enableWallet)
{ {
frameBlocksLayout->addStretch(); frameBlocksLayout->addStretch();
@@ -925,7 +925,7 @@ void BitcoinGUI::updateNetworkState()
tooltip = QString("<nobr>") + tooltip + QString("</nobr>"); tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
connectionsControl->setToolTip(tooltip); 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) 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 // Set icon state: spinning if catching up, tick otherwise
if (secs < MAX_BLOCK_TIME_GAP) { if (secs < MAX_BLOCK_TIME_GAP) {
tooltip = tr("Up to date") + QString(".<br>") + tooltip; 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 #ifdef ENABLE_WALLET
if(walletFrame) if(walletFrame)
@@ -1047,9 +1047,9 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
tooltip = tr("Catching up...") + QString("<br>") + tooltip; tooltip = tr("Catching up...") + QString("<br>") + tooltip;
if(count != prevBlocks) if(count != prevBlocks)
{ {
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString( labelBlocksIcon->setThemedPixmap(
":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0'))) QString(":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')),
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES; spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
} }
prevBlocks = count; prevBlocks = count;
@@ -1325,7 +1325,7 @@ void BitcoinGUI::updateProxyIcon()
if (proxy_enabled) { if (proxy_enabled) {
if (!GUIUtil::HasPixmap(labelProxyIcon)) { if (!GUIUtil::HasPixmap(labelProxyIcon)) {
QString ip_port_q = QString::fromStdString(ip_port); 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)); labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
} else { } else {
labelProxyIcon->show(); labelProxyIcon->show();
+5
View File
@@ -817,6 +817,11 @@ void ThemedLabel::updateThemedPixmap()
setPixmap(m_platform_style->SingleColorIcon(m_image_filename).pixmap(m_pixmap_width, m_pixmap_height)); 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) void ClickableLabel::mouseReleaseEvent(QMouseEvent *event)
{ {
Q_EMIT clicked(event->pos()); Q_EMIT clicked(event->pos());
+4 -1
View File
@@ -241,10 +241,13 @@ namespace GUIUtil
void updateThemedPixmap(); void updateThemedPixmap();
}; };
class ClickableLabel : public QLabel class ClickableLabel : public ThemedLabel
{ {
Q_OBJECT Q_OBJECT
public:
explicit ClickableLabel(const PlatformStyle* platform_style, QWidget* parent = nullptr);
Q_SIGNALS: Q_SIGNALS:
/** Emitted when the label is clicked. The relative mouse coordinates of the click are /** Emitted when the label is clicked. The relative mouse coordinates of the click are
* passed to the signal. * passed to the signal.