Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 41 additions & 18 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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%
Expand All @@ -1275,15 +1285,15 @@ 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);
encryptWalletAction->setEnabled(false);
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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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."));
Expand All @@ -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 */
Expand All @@ -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()
{
Expand Down
7 changes: 5 additions & 2 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <config/bitcoin-config.h>
#endif

#include <qt/guiutil.h>
#include <qt/optionsdialog.h>

#include <amount.h>
Expand Down Expand Up @@ -121,8 +122,8 @@ class BitcoinGUI : public QMainWindow
WalletFrame* walletFrame = nullptr;

UnitDisplayStatusBarControl* unitDisplayControl = nullptr;
QLabel* labelWalletEncryptionIcon = nullptr;
QLabel* labelWalletHDStatusIcon = nullptr;
GUIUtil::ThemedLabel* labelWalletEncryptionIcon = nullptr;
GUIUtil::ThemedLabel* labelWalletHDStatusIcon = nullptr;
GUIUtil::ClickableLabel* labelProxyIcon = nullptr;
GUIUtil::ClickableLabel* connectionsControl = nullptr;
GUIUtil::ClickableLabel* labelBlocksIcon = nullptr;
Expand Down Expand Up @@ -333,10 +334,12 @@ class UnitDisplayStatusBarControl : public QLabel
protected:
/** So that it responds to left-button clicks */
void mousePressEvent(QMouseEvent *event) override;
void changeEvent(QEvent* e) override;

private:
OptionsModel *optionsModel;
QMenu* menu;
const PlatformStyle* m_platform_style;

/** Shows context menu with Display Unit options by the mouse coordinates */
void onDisplayUnitsClicked(const QPoint& point);
Expand Down
9 changes: 9 additions & 0 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,15 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
label->setVisible(nChange < 0);
}

void CoinControlDialog::changeEvent(QEvent* e)
{
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) {
updateView();
}
#endif
}

void CoinControlDialog::updateView()
{
if (!model || !model->getOptionsModel() || !model->getAddressTableModel())
Expand Down
3 changes: 3 additions & 0 deletions src/qt/coincontroldialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class CoinControlDialog : public QDialog
static QList<CAmount> payAmounts;
static bool fSubtractFeeFromAmount;

protected:
void changeEvent(QEvent* e) override;

private:
Ui::CoinControlDialog *ui;
CCoinControl& m_coin_control;
Expand Down
36 changes: 36 additions & 0 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <qt/bitcoinaddressvalidator.h>
#include <qt/bitcoinunits.h>
#include <qt/platformstyle.h>
#include <qt/qvalidatedlineedit.h>
#include <qt/sendcoinsrecipient.h>

Expand Down Expand Up @@ -61,6 +62,7 @@
#include <QUrlQuery>
#include <QtGlobal>

#include <cassert>
#include <chrono>

#if defined(Q_OS_MAC)
Expand Down Expand Up @@ -786,6 +788,40 @@ qreal calculateIdealFontSize(int width, const QString& text, QFont font, qreal m
return font_size;
}

ThemedLabel::ThemedLabel(const PlatformStyle* platform_style, QWidget* parent)
: QLabel{parent}, m_platform_style{platform_style}
{
assert(m_platform_style);
}

void ThemedLabel::setThemedPixmap(const QString& image_filename, int width, int height)
{
m_image_filename = image_filename;
m_pixmap_width = width;
m_pixmap_height = height;
updateThemedPixmap();
}

void ThemedLabel::changeEvent(QEvent* e)
{
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) {
updateThemedPixmap();
}
#endif
QLabel::changeEvent(e);
}

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());
Expand Down
25 changes: 24 additions & 1 deletion src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <chrono>
#include <utility>

class PlatformStyle;
class QValidatedLineEdit;
class SendCoinsRecipient;

Expand Down Expand Up @@ -221,10 +222,32 @@ namespace GUIUtil

qreal calculateIdealFontSize(int width, const QString& text, QFont font, qreal minPointSize = 4, qreal startPointSize = 14);

class ClickableLabel : public QLabel
class ThemedLabel : public QLabel
{
Q_OBJECT

public:
explicit ThemedLabel(const PlatformStyle* platform_style, QWidget* parent = nullptr);
void setThemedPixmap(const QString& image_filename, int width, int height);

protected:
void changeEvent(QEvent* e) override;

private:
const PlatformStyle* m_platform_style;
QString m_image_filename;
int m_pixmap_width;
int m_pixmap_height;
void updateThemedPixmap();
};

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.
Expand Down
15 changes: 14 additions & 1 deletion src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class TxViewDelegate : public QAbstractItemDelegate
{
QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole));
QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight);
iconWatchonly = platformStyle->TextColorIcon(iconWatchonly);
iconWatchonly.paint(painter, watchonlyRect);
address_rect_min_width += 5 + watchonlyRect.width();
}
Expand Down Expand Up @@ -143,14 +144,15 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
ui(new Ui::OverviewPage),
clientModel(nullptr),
walletModel(nullptr),
m_platform_style{platformStyle},
txdelegate(new TxViewDelegate(platformStyle, this))
{
ui->setupUi(this);

m_balances.balance = -1;

// use a SingleColorIcon for the "out of sync warning" icon
QIcon icon = platformStyle->SingleColorIcon(":/icons/warning");
QIcon icon = m_platform_style->SingleColorIcon(QStringLiteral(":/icons/warning"));
ui->labelTransactionsStatus->setIcon(icon);
ui->labelWalletStatus->setIcon(icon);

Expand Down Expand Up @@ -298,6 +300,17 @@ void OverviewPage::setWalletModel(WalletModel *model)
updateDisplayUnit();
}

void OverviewPage::changeEvent(QEvent* e)
{
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) {
QIcon icon = m_platform_style->SingleColorIcon(QStringLiteral(":/icons/warning"));
ui->labelTransactionsStatus->setIcon(icon);
ui->labelWalletStatus->setIcon(icon);
}
#endif
}

void OverviewPage::updateDisplayUnit()
{
if(walletModel && walletModel->getOptionsModel())
Expand Down
5 changes: 5 additions & 0 deletions src/qt/overviewpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@ public Q_SLOTS:
void transactionClicked(const QModelIndex &index);
void outOfSyncWarningClicked();

protected:
void changeEvent(QEvent* e) override;

private:
Ui::OverviewPage *ui;
ClientModel *clientModel;
WalletModel *walletModel;
interfaces::WalletBalances m_balances;
bool m_privacy{false};

const PlatformStyle* m_platform_style;

TxViewDelegate *txdelegate;
std::unique_ptr<TransactionFilterProxy> filter;

Expand Down
Loading