Merge bitcoin-core/gui#366: Dark Mode fixes/portability

9d5bf6bf01 GUI: Always call parent changeEvent handler (Luke Dashjr)
c901d4d8ce GUI: Enable palette change adaptation on all platforms (Luke Dashjr)

Pull request description:

  The changes to support macOS "Dark Mode" are valid for any platform, and should work so long as Qt implements the PaletteChange event. (Worst case, we're no worse off with trying.)

  Additionally, we shouldn't block the parent classes from implementing event handlers. Who knows what side effects that could have.

ACKs for top commit:
  hebasto:
    ACK 9d5bf6bf01, tested on Linux Mint 20.1 (Qt 5.12.8) with the [`qt5ct`](https://packages.ubuntu.com/focal/qt5ct) package installed.
  kristapsk:
    ACK 9d5bf6bf01. Tested on Gentoo Linux with Xfce4 and Qt 5.15.2, does not break anything on my computer.

Tree-SHA512: dce2fff0ff129eda208132390a37424ff9607539287dbdbfdfd659ed9c4ea0472541e987489a04fd935e391dc006a35bfc9cfa9bcff33602b7dbd29b81c51626
This commit is contained in:
Hennadii Stepanov 2021-07-01 08:55:30 +03:00
commit 34f554dbd3
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
8 changed files with 15 additions and 18 deletions

View file

@ -1173,14 +1173,12 @@ 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) { if (e->type() == QEvent::PaletteChange) {
overviewAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/overview"))); overviewAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/overview")));
sendCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/send"))); sendCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/send")));
receiveCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/receiving_addresses"))); receiveCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/receiving_addresses")));
historyAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/history"))); historyAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/history")));
} }
#endif
QMainWindow::changeEvent(e); QMainWindow::changeEvent(e);
@ -1511,14 +1509,14 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
void UnitDisplayStatusBarControl::changeEvent(QEvent* e) void UnitDisplayStatusBarControl::changeEvent(QEvent* e)
{ {
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) { if (e->type() == QEvent::PaletteChange) {
QString style = QString("QLabel { color : %1 }").arg(m_platform_style->SingleColor().name()); QString style = QString("QLabel { color : %1 }").arg(m_platform_style->SingleColor().name());
if (style != styleSheet()) { if (style != styleSheet()) {
setStyleSheet(style); setStyleSheet(style);
} }
} }
#endif
QLabel::changeEvent(e);
} }
/** 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. */

View file

@ -564,11 +564,11 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
void CoinControlDialog::changeEvent(QEvent* e) void CoinControlDialog::changeEvent(QEvent* e)
{ {
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) { if (e->type() == QEvent::PaletteChange) {
updateView(); updateView();
} }
#endif
QDialog::changeEvent(e);
} }
void CoinControlDialog::updateView() void CoinControlDialog::updateView()

View file

@ -809,11 +809,10 @@ void ThemedLabel::setThemedPixmap(const QString& image_filename, int width, int
void ThemedLabel::changeEvent(QEvent* e) void ThemedLabel::changeEvent(QEvent* e)
{ {
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) { if (e->type() == QEvent::PaletteChange) {
updateThemedPixmap(); updateThemedPixmap();
} }
#endif
QLabel::changeEvent(e); QLabel::changeEvent(e);
} }

View file

@ -297,13 +297,13 @@ void OverviewPage::setWalletModel(WalletModel *model)
void OverviewPage::changeEvent(QEvent* e) void OverviewPage::changeEvent(QEvent* e)
{ {
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) { if (e->type() == QEvent::PaletteChange) {
QIcon icon = m_platform_style->SingleColorIcon(QStringLiteral(":/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);
} }
#endif
QWidget::changeEvent(e);
} }
void OverviewPage::updateDisplayUnit() void OverviewPage::updateDisplayUnit()

View file

@ -882,7 +882,6 @@ void RPCConsole::keyPressEvent(QKeyEvent *event)
void RPCConsole::changeEvent(QEvent* e) void RPCConsole::changeEvent(QEvent* e)
{ {
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) { if (e->type() == QEvent::PaletteChange) {
ui->clearButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove"))); ui->clearButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
ui->fontBiggerButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/fontbigger"))); ui->fontBiggerButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/fontbigger")));
@ -896,7 +895,8 @@ void RPCConsole::changeEvent(QEvent* e)
platformStyle->SingleColorImage(ICON_MAPPING[i].source).scaled(QSize(consoleFontSize * 2, consoleFontSize * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); platformStyle->SingleColorImage(ICON_MAPPING[i].source).scaled(QSize(consoleFontSize * 2, consoleFontSize * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
} }
} }
#endif
QWidget::changeEvent(e);
} }
void RPCConsole::message(int category, const QString &message, bool html) void RPCConsole::message(int category, const QString &message, bool html)

View file

@ -238,7 +238,6 @@ void SendCoinsEntry::updateDisplayUnit()
void SendCoinsEntry::changeEvent(QEvent* e) void SendCoinsEntry::changeEvent(QEvent* e)
{ {
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) { if (e->type() == QEvent::PaletteChange) {
ui->addressBookButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/address-book"))); ui->addressBookButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/address-book")));
ui->pasteButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/editpaste"))); ui->pasteButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/editpaste")));
@ -246,7 +245,8 @@ void SendCoinsEntry::changeEvent(QEvent* e)
ui->deleteButton_is->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove"))); ui->deleteButton_is->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
ui->deleteButton_s->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove"))); ui->deleteButton_s->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
} }
#endif
QStackedWidget::changeEvent(e);
} }
bool SendCoinsEntry::updateLabel(const QString &address) bool SendCoinsEntry::updateLabel(const QString &address)

View file

@ -286,7 +286,6 @@ bool SignVerifyMessageDialog::eventFilter(QObject *object, QEvent *event)
void SignVerifyMessageDialog::changeEvent(QEvent* e) void SignVerifyMessageDialog::changeEvent(QEvent* e)
{ {
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) { if (e->type() == QEvent::PaletteChange) {
ui->addressBookButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/address-book"))); ui->addressBookButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/address-book")));
ui->pasteButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/editpaste"))); ui->pasteButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/editpaste")));
@ -297,5 +296,6 @@ void SignVerifyMessageDialog::changeEvent(QEvent* e)
ui->verifyMessageButton_VM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/transaction_0"))); ui->verifyMessageButton_VM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/transaction_0")));
ui->clearButton_VM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove"))); ui->clearButton_VM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
} }
#endif
QDialog::changeEvent(e);
} }

View file

@ -245,7 +245,6 @@ void TransactionView::setModel(WalletModel *_model)
void TransactionView::changeEvent(QEvent* e) void TransactionView::changeEvent(QEvent* e)
{ {
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) { if (e->type() == QEvent::PaletteChange) {
watchOnlyWidget->setItemIcon( watchOnlyWidget->setItemIcon(
TransactionFilterProxy::WatchOnlyFilter_Yes, TransactionFilterProxy::WatchOnlyFilter_Yes,
@ -254,7 +253,8 @@ void TransactionView::changeEvent(QEvent* e)
TransactionFilterProxy::WatchOnlyFilter_No, TransactionFilterProxy::WatchOnlyFilter_No,
m_platform_style->SingleColorIcon(QStringLiteral(":/icons/eye_minus"))); m_platform_style->SingleColorIcon(QStringLiteral(":/icons/eye_minus")));
} }
#endif
QWidget::changeEvent(e);
} }
void TransactionView::chooseDate(int idx) void TransactionView::chooseDate(int idx)