Merge bitcoin-core/gui#275: Support runtime appearance adjustment on macOS
c231254a65qt: Make TransactionView aware of runtime palette change (Hennadii Stepanov)2b622d4aceqt: Make CoinControlDialog aware of runtime palette change (Hennadii Stepanov)97a6b5e06aqt: Make OverviewPage aware of runtime palette change (Hennadii Stepanov)d05f1b278dqt: Make UnitDisplayStatusBarControl aware of runtime palette change (Hennadii Stepanov)6b2ce65392qt: Replace base class of ClickableLabel with ThemedLabel (Hennadii Stepanov)ff530a2093qt: Use GUIUtil::ThemedLabel class (Hennadii Stepanov)d99ef327a8qt: Add GUIUtil::ThemedLabel class (Hennadii Stepanov)c054720e08qt: Make SignVerifyMessageDialog aware of runtime palette change (Hennadii Stepanov)0dcc3fac43qt: Make SendCoinsEntry aware of runtime palette change (Hennadii Stepanov)fa18d28e12qt: Make RPCConsole aware of runtime palette change (Hennadii Stepanov)f1083826e3qt: Make BitcoinGUI aware of runtime palette change (Hennadii Stepanov)ce17861dc4qt: 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: tACKc231254a65on macOS 11.4 goums: ACKc231254a65promag: Tested ACKc231254a65on macOS Big Sur arm64. jarolrod: tACKc231254a65Tree-SHA512: 122dda3e4c9703f68cec60613c536ca59d04c93f2c03398559f2361b8d279ae534800e8e677d94a33e10e769d00be54295a704e98afa2e986a06146b9f164854
This commit is contained in:
18 files changed
+228
-41
No files matched your search
+41
-18
@@ -150,11 +150,11 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
|
|||||||
frameBlocksLayout->setContentsMargins(3,0,3,0);
|
frameBlocksLayout->setContentsMargins(3,0,3,0);
|
||||||
frameBlocksLayout->setSpacing(3);
|
frameBlocksLayout->setSpacing(3);
|
||||||
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
|
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
|
||||||
labelWalletEncryptionIcon = new QLabel();
|
labelWalletEncryptionIcon = new GUIUtil::ThemedLabel(platformStyle);
|
||||||
labelWalletHDStatusIcon = new QLabel();
|
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;
|
||||||
@@ -1138,7 +1138,17 @@ void BitcoinGUI::message(const QString& title, QString message, unsigned int sty
|
|||||||
|
|
||||||
void BitcoinGUI::changeEvent(QEvent *e)
|
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);
|
QMainWindow::changeEvent(e);
|
||||||
|
|
||||||
#ifndef Q_OS_MAC // Ignored on Mac
|
#ifndef Q_OS_MAC // Ignored on Mac
|
||||||
if(e->type() == QEvent::WindowStateChange)
|
if(e->type() == QEvent::WindowStateChange)
|
||||||
{
|
{
|
||||||
@@ -1256,7 +1266,7 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
|
|||||||
|
|
||||||
void BitcoinGUI::setHDStatus(bool privkeyDisabled, int hdEnabled)
|
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->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();
|
labelWalletHDStatusIcon->show();
|
||||||
// eventually disable the QLabel to set its opacity to 50%
|
// eventually disable the QLabel to set its opacity to 50%
|
||||||
@@ -1275,7 +1285,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
|
|||||||
break;
|
break;
|
||||||
case WalletModel::Unlocked:
|
case WalletModel::Unlocked:
|
||||||
labelWalletEncryptionIcon->show();
|
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>"));
|
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
|
||||||
encryptWalletAction->setChecked(true);
|
encryptWalletAction->setChecked(true);
|
||||||
changePassphraseAction->setEnabled(true);
|
changePassphraseAction->setEnabled(true);
|
||||||
@@ -1283,7 +1293,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
|
|||||||
break;
|
break;
|
||||||
case WalletModel::Locked:
|
case WalletModel::Locked:
|
||||||
labelWalletEncryptionIcon->show();
|
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>"));
|
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
|
||||||
encryptWalletAction->setChecked(true);
|
encryptWalletAction->setChecked(true);
|
||||||
changePassphraseAction->setEnabled(true);
|
changePassphraseAction->setEnabled(true);
|
||||||
@@ -1315,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();
|
||||||
@@ -1440,9 +1450,10 @@ bool BitcoinGUI::isPrivacyModeActivated() const
|
|||||||
return m_mask_values_action->isChecked();
|
return m_mask_values_action->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
|
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
|
||||||
optionsModel(nullptr),
|
: optionsModel(nullptr),
|
||||||
menu(nullptr)
|
menu(nullptr),
|
||||||
|
m_platform_style{platformStyle}
|
||||||
{
|
{
|
||||||
createContextMenu();
|
createContextMenu();
|
||||||
setToolTip(tr("Unit to show amounts in. Click to select another unit."));
|
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);
|
setMinimumSize(max_width, 0);
|
||||||
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
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 */
|
/** So that it responds to button clicks */
|
||||||
@@ -1464,6 +1475,18 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
|
|||||||
onDisplayUnitsClicked(event->pos());
|
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. */
|
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
|
||||||
void UnitDisplayStatusBarControl::createContextMenu()
|
void UnitDisplayStatusBarControl::createContextMenu()
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-2
@@ -9,6 +9,7 @@
|
|||||||
#include <config/bitcoin-config.h>
|
#include <config/bitcoin-config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <qt/guiutil.h>
|
||||||
#include <qt/optionsdialog.h>
|
#include <qt/optionsdialog.h>
|
||||||
|
|
||||||
#include <amount.h>
|
#include <amount.h>
|
||||||
@@ -121,8 +122,8 @@ private:
|
|||||||
WalletFrame* walletFrame = nullptr;
|
WalletFrame* walletFrame = nullptr;
|
||||||
|
|
||||||
UnitDisplayStatusBarControl* unitDisplayControl = nullptr;
|
UnitDisplayStatusBarControl* unitDisplayControl = nullptr;
|
||||||
QLabel* labelWalletEncryptionIcon = nullptr;
|
GUIUtil::ThemedLabel* labelWalletEncryptionIcon = nullptr;
|
||||||
QLabel* labelWalletHDStatusIcon = nullptr;
|
GUIUtil::ThemedLabel* labelWalletHDStatusIcon = nullptr;
|
||||||
GUIUtil::ClickableLabel* labelProxyIcon = nullptr;
|
GUIUtil::ClickableLabel* labelProxyIcon = nullptr;
|
||||||
GUIUtil::ClickableLabel* connectionsControl = nullptr;
|
GUIUtil::ClickableLabel* connectionsControl = nullptr;
|
||||||
GUIUtil::ClickableLabel* labelBlocksIcon = nullptr;
|
GUIUtil::ClickableLabel* labelBlocksIcon = nullptr;
|
||||||
@@ -333,10 +334,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
/** So that it responds to left-button clicks */
|
/** So that it responds to left-button clicks */
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
void changeEvent(QEvent* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OptionsModel *optionsModel;
|
OptionsModel *optionsModel;
|
||||||
QMenu* menu;
|
QMenu* menu;
|
||||||
|
const PlatformStyle* m_platform_style;
|
||||||
|
|
||||||
/** Shows context menu with Display Unit options by the mouse coordinates */
|
/** Shows context menu with Display Unit options by the mouse coordinates */
|
||||||
void onDisplayUnitsClicked(const QPoint& point);
|
void onDisplayUnitsClicked(const QPoint& point);
|
||||||
|
|||||||
@@ -562,6 +562,15 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
|
|||||||
label->setVisible(nChange < 0);
|
label->setVisible(nChange < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoinControlDialog::changeEvent(QEvent* e)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
if (e->type() == QEvent::PaletteChange) {
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void CoinControlDialog::updateView()
|
void CoinControlDialog::updateView()
|
||||||
{
|
{
|
||||||
if (!model || !model->getOptionsModel() || !model->getAddressTableModel())
|
if (!model || !model->getOptionsModel() || !model->getAddressTableModel())
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ public:
|
|||||||
static QList<CAmount> payAmounts;
|
static QList<CAmount> payAmounts;
|
||||||
static bool fSubtractFeeFromAmount;
|
static bool fSubtractFeeFromAmount;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent(QEvent* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::CoinControlDialog *ui;
|
Ui::CoinControlDialog *ui;
|
||||||
CCoinControl& m_coin_control;
|
CCoinControl& m_coin_control;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <qt/bitcoinaddressvalidator.h>
|
#include <qt/bitcoinaddressvalidator.h>
|
||||||
#include <qt/bitcoinunits.h>
|
#include <qt/bitcoinunits.h>
|
||||||
|
#include <qt/platformstyle.h>
|
||||||
#include <qt/qvalidatedlineedit.h>
|
#include <qt/qvalidatedlineedit.h>
|
||||||
#include <qt/sendcoinsrecipient.h>
|
#include <qt/sendcoinsrecipient.h>
|
||||||
|
|
||||||
@@ -61,6 +62,7 @@
|
|||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
@@ -791,6 +793,40 @@ qreal calculateIdealFontSize(int width, const QString& text, QFont font, qreal m
|
|||||||
return font_size;
|
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)
|
void ClickableLabel::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_EMIT clicked(event->pos());
|
Q_EMIT clicked(event->pos());
|
||||||
|
|||||||
+24
-1
@@ -27,6 +27,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
class PlatformStyle;
|
||||||
class QValidatedLineEdit;
|
class QValidatedLineEdit;
|
||||||
class SendCoinsRecipient;
|
class SendCoinsRecipient;
|
||||||
|
|
||||||
@@ -231,10 +232,32 @@ namespace GUIUtil
|
|||||||
|
|
||||||
qreal calculateIdealFontSize(int width, const QString& text, QFont font, qreal minPointSize = 4, qreal startPointSize = 14);
|
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
|
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:
|
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.
|
||||||
|
|||||||
+14
-1
@@ -78,6 +78,7 @@ public:
|
|||||||
{
|
{
|
||||||
QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole));
|
QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole));
|
||||||
QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight);
|
QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight);
|
||||||
|
iconWatchonly = platformStyle->TextColorIcon(iconWatchonly);
|
||||||
iconWatchonly.paint(painter, watchonlyRect);
|
iconWatchonly.paint(painter, watchonlyRect);
|
||||||
address_rect_min_width += 5 + watchonlyRect.width();
|
address_rect_min_width += 5 + watchonlyRect.width();
|
||||||
}
|
}
|
||||||
@@ -143,6 +144,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
|
|||||||
ui(new Ui::OverviewPage),
|
ui(new Ui::OverviewPage),
|
||||||
clientModel(nullptr),
|
clientModel(nullptr),
|
||||||
walletModel(nullptr),
|
walletModel(nullptr),
|
||||||
|
m_platform_style{platformStyle},
|
||||||
txdelegate(new TxViewDelegate(platformStyle, this))
|
txdelegate(new TxViewDelegate(platformStyle, this))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@@ -150,7 +152,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
|
|||||||
m_balances.balance = -1;
|
m_balances.balance = -1;
|
||||||
|
|
||||||
// use a SingleColorIcon for the "out of sync warning" icon
|
// 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->labelTransactionsStatus->setIcon(icon);
|
||||||
ui->labelWalletStatus->setIcon(icon);
|
ui->labelWalletStatus->setIcon(icon);
|
||||||
|
|
||||||
@@ -298,6 +300,17 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
|||||||
updateDisplayUnit();
|
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()
|
void OverviewPage::updateDisplayUnit()
|
||||||
{
|
{
|
||||||
if(walletModel && walletModel->getOptionsModel())
|
if(walletModel && walletModel->getOptionsModel())
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ Q_SIGNALS:
|
|||||||
void transactionClicked(const QModelIndex &index);
|
void transactionClicked(const QModelIndex &index);
|
||||||
void outOfSyncWarningClicked();
|
void outOfSyncWarningClicked();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent(QEvent* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::OverviewPage *ui;
|
Ui::OverviewPage *ui;
|
||||||
ClientModel *clientModel;
|
ClientModel *clientModel;
|
||||||
@@ -52,6 +55,8 @@ private:
|
|||||||
interfaces::WalletBalances m_balances;
|
interfaces::WalletBalances m_balances;
|
||||||
bool m_privacy{false};
|
bool m_privacy{false};
|
||||||
|
|
||||||
|
const PlatformStyle* m_platform_style;
|
||||||
|
|
||||||
TxViewDelegate *txdelegate;
|
TxViewDelegate *txdelegate;
|
||||||
std::unique_ptr<TransactionFilterProxy> filter;
|
std::unique_ptr<TransactionFilterProxy> filter;
|
||||||
|
|
||||||
|
|||||||
+15
-12
@@ -71,25 +71,28 @@ PlatformStyle::PlatformStyle(const QString &_name, bool _imagesOnButtons, bool _
|
|||||||
name(_name),
|
name(_name),
|
||||||
imagesOnButtons(_imagesOnButtons),
|
imagesOnButtons(_imagesOnButtons),
|
||||||
colorizeIcons(_colorizeIcons),
|
colorizeIcons(_colorizeIcons),
|
||||||
useExtraSpacing(_useExtraSpacing),
|
useExtraSpacing(_useExtraSpacing)
|
||||||
singleColor(0,0,0),
|
{
|
||||||
textColor(0,0,0)
|
}
|
||||||
|
|
||||||
|
QColor PlatformStyle::TextColor() const
|
||||||
|
{
|
||||||
|
return QApplication::palette().color(QPalette::WindowText);
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor PlatformStyle::SingleColor() const
|
||||||
{
|
{
|
||||||
// Determine icon highlighting color
|
|
||||||
if (colorizeIcons) {
|
if (colorizeIcons) {
|
||||||
const QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight));
|
const QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight));
|
||||||
const QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText));
|
const QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText));
|
||||||
const QColor colorText(QApplication::palette().color(QPalette::WindowText));
|
const QColor colorText(QApplication::palette().color(QPalette::WindowText));
|
||||||
const int colorTextLightness = colorText.lightness();
|
const int colorTextLightness = colorText.lightness();
|
||||||
QColor colorbase;
|
if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness)) {
|
||||||
if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness))
|
return colorHighlightBg;
|
||||||
colorbase = colorHighlightBg;
|
}
|
||||||
else
|
return colorHighlightFg;
|
||||||
colorbase = colorHighlightFg;
|
|
||||||
singleColor = colorbase;
|
|
||||||
}
|
}
|
||||||
// Determine text color
|
return {0, 0, 0};
|
||||||
textColor = QColor(QApplication::palette().color(QPalette::WindowText));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage PlatformStyle::SingleColorImage(const QString& filename) const
|
QImage PlatformStyle::SingleColorImage(const QString& filename) const
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ public:
|
|||||||
bool getImagesOnButtons() const { return imagesOnButtons; }
|
bool getImagesOnButtons() const { return imagesOnButtons; }
|
||||||
bool getUseExtraSpacing() const { return useExtraSpacing; }
|
bool getUseExtraSpacing() const { return useExtraSpacing; }
|
||||||
|
|
||||||
QColor TextColor() const { return textColor; }
|
QColor TextColor() const;
|
||||||
QColor SingleColor() const { return singleColor; }
|
QColor SingleColor() const;
|
||||||
|
|
||||||
/** Colorize an image (given filename) with the icon color */
|
/** Colorize an image (given filename) with the icon color */
|
||||||
QImage SingleColorImage(const QString& filename) const;
|
QImage SingleColorImage(const QString& filename) const;
|
||||||
@@ -43,9 +43,6 @@ private:
|
|||||||
bool imagesOnButtons;
|
bool imagesOnButtons;
|
||||||
bool colorizeIcons;
|
bool colorizeIcons;
|
||||||
bool useExtraSpacing;
|
bool useExtraSpacing;
|
||||||
QColor singleColor;
|
|
||||||
QColor textColor;
|
|
||||||
/* ... more to come later */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_QT_PLATFORMSTYLE_H
|
#endif // BITCOIN_QT_PLATFORMSTYLE_H
|
||||||
|
|||||||
@@ -843,6 +843,25 @@ void RPCConsole::keyPressEvent(QKeyEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RPCConsole::changeEvent(QEvent* e)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
if (e->type() == QEvent::PaletteChange) {
|
||||||
|
ui->clearButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
|
||||||
|
ui->fontBiggerButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/fontbigger")));
|
||||||
|
ui->fontSmallerButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/fontsmaller")));
|
||||||
|
ui->promptIcon->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/prompticon")));
|
||||||
|
|
||||||
|
for (int i = 0; ICON_MAPPING[i].url; ++i) {
|
||||||
|
ui->messagesWidget->document()->addResource(
|
||||||
|
QTextDocument::ImageResource,
|
||||||
|
QUrl(ICON_MAPPING[i].url),
|
||||||
|
platformStyle->SingleColorImage(ICON_MAPPING[i].source).scaled(QSize(consoleFontSize * 2, consoleFontSize * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void RPCConsole::message(int category, const QString &message, bool html)
|
void RPCConsole::message(int category, const QString &message, bool html)
|
||||||
{
|
{
|
||||||
QTime time = QTime::currentTime();
|
QTime time = QTime::currentTime();
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual bool eventFilter(QObject* obj, QEvent *event) override;
|
virtual bool eventFilter(QObject* obj, QEvent *event) override;
|
||||||
void keyPressEvent(QKeyEvent *) override;
|
void keyPressEvent(QKeyEvent *) override;
|
||||||
|
void changeEvent(QEvent* e) override;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void on_lineEdit_returnPressed();
|
void on_lineEdit_returnPressed();
|
||||||
|
|||||||
@@ -236,6 +236,19 @@ void SendCoinsEntry::updateDisplayUnit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SendCoinsEntry::changeEvent(QEvent* e)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
if (e->type() == QEvent::PaletteChange) {
|
||||||
|
ui->addressBookButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/address-book")));
|
||||||
|
ui->pasteButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/editpaste")));
|
||||||
|
ui->deleteButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
|
||||||
|
ui->deleteButton_is->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
|
||||||
|
ui->deleteButton_s->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool SendCoinsEntry::updateLabel(const QString &address)
|
bool SendCoinsEntry::updateLabel(const QString &address)
|
||||||
{
|
{
|
||||||
if(!model)
|
if(!model)
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ private Q_SLOTS:
|
|||||||
void on_pasteButton_clicked();
|
void on_pasteButton_clicked();
|
||||||
void updateDisplayUnit();
|
void updateDisplayUnit();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent(QEvent* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SendCoinsRecipient recipient;
|
SendCoinsRecipient recipient;
|
||||||
Ui::SendCoinsEntry *ui;
|
Ui::SendCoinsEntry *ui;
|
||||||
|
|||||||
@@ -283,3 +283,19 @@ bool SignVerifyMessageDialog::eventFilter(QObject *object, QEvent *event)
|
|||||||
}
|
}
|
||||||
return QDialog::eventFilter(object, event);
|
return QDialog::eventFilter(object, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SignVerifyMessageDialog::changeEvent(QEvent* e)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
if (e->type() == QEvent::PaletteChange) {
|
||||||
|
ui->addressBookButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/address-book")));
|
||||||
|
ui->pasteButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/editpaste")));
|
||||||
|
ui->copySignatureButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/editcopy")));
|
||||||
|
ui->signMessageButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/edit")));
|
||||||
|
ui->clearButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
|
||||||
|
ui->addressBookButton_VM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/address-book")));
|
||||||
|
ui->verifyMessageButton_VM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/transaction_0")));
|
||||||
|
ui->clearButton_VM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *object, QEvent *event) override;
|
bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
|
void changeEvent(QEvent* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SignVerifyMessageDialog *ui;
|
Ui::SignVerifyMessageDialog *ui;
|
||||||
|
|||||||
@@ -37,8 +37,8 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) :
|
TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent)
|
||||||
QWidget(parent)
|
: QWidget(parent), m_platform_style{platformStyle}
|
||||||
{
|
{
|
||||||
// Build filter row
|
// Build filter row
|
||||||
setContentsMargins(0,0,0,0);
|
setContentsMargins(0,0,0,0);
|
||||||
@@ -243,6 +243,20 @@ void TransactionView::setModel(WalletModel *_model)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransactionView::changeEvent(QEvent* e)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
if (e->type() == QEvent::PaletteChange) {
|
||||||
|
watchOnlyWidget->setItemIcon(
|
||||||
|
TransactionFilterProxy::WatchOnlyFilter_Yes,
|
||||||
|
m_platform_style->SingleColorIcon(QStringLiteral(":/icons/eye_plus")));
|
||||||
|
watchOnlyWidget->setItemIcon(
|
||||||
|
TransactionFilterProxy::WatchOnlyFilter_No,
|
||||||
|
m_platform_style->SingleColorIcon(QStringLiteral(":/icons/eye_minus")));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void TransactionView::chooseDate(int idx)
|
void TransactionView::chooseDate(int idx)
|
||||||
{
|
{
|
||||||
if (!transactionProxyModel) return;
|
if (!transactionProxyModel) return;
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ public:
|
|||||||
MINIMUM_COLUMN_WIDTH = 23
|
MINIMUM_COLUMN_WIDTH = 23
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent(QEvent* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WalletModel *model{nullptr};
|
WalletModel *model{nullptr};
|
||||||
TransactionFilterProxy *transactionProxyModel{nullptr};
|
TransactionFilterProxy *transactionProxyModel{nullptr};
|
||||||
@@ -85,6 +88,8 @@ private:
|
|||||||
|
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|
||||||
|
const PlatformStyle* m_platform_style;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void contextualMenu(const QPoint &);
|
void contextualMenu(const QPoint &);
|
||||||
void dateRangeChanged();
|
void dateRangeChanged();
|
||||||
|
|||||||
Reference in new issue
Block a user