Skip to content

Commit 34f554d

Browse files
committed
Merge bitcoin-core#366: Dark Mode fixes/portability
9d5bf6b GUI: Always call parent changeEvent handler (Luke Dashjr) c901d4d 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 9d5bf6b, tested on Linux Mint 20.1 (Qt 5.12.8) with the [`qt5ct`](https://packages.ubuntu.com/focal/qt5ct) package installed. kristapsk: ACK 9d5bf6b. Tested on Gentoo Linux with Xfce4 and Qt 5.15.2, does not break anything on my computer. Tree-SHA512: dce2fff0ff129eda208132390a37424ff9607539287dbdbfdfd659ed9c4ea0472541e987489a04fd935e391dc006a35bfc9cfa9bcff33602b7dbd29b81c51626
2 parents 5a95c51 + 9d5bf6b commit 34f554d

File tree

8 files changed

+15
-18
lines changed

8 files changed

+15
-18
lines changed

src/qt/bitcoingui.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,14 +1173,12 @@ void BitcoinGUI::message(const QString& title, QString message, unsigned int sty
11731173

11741174
void BitcoinGUI::changeEvent(QEvent *e)
11751175
{
1176-
#ifdef Q_OS_MACOS
11771176
if (e->type() == QEvent::PaletteChange) {
11781177
overviewAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/overview")));
11791178
sendCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/send")));
11801179
receiveCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/receiving_addresses")));
11811180
historyAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/history")));
11821181
}
1183-
#endif
11841182

11851183
QMainWindow::changeEvent(e);
11861184

@@ -1511,14 +1509,14 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
15111509

15121510
void UnitDisplayStatusBarControl::changeEvent(QEvent* e)
15131511
{
1514-
#ifdef Q_OS_MACOS
15151512
if (e->type() == QEvent::PaletteChange) {
15161513
QString style = QString("QLabel { color : %1 }").arg(m_platform_style->SingleColor().name());
15171514
if (style != styleSheet()) {
15181515
setStyleSheet(style);
15191516
}
15201517
}
1521-
#endif
1518+
1519+
QLabel::changeEvent(e);
15221520
}
15231521

15241522
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */

src/qt/coincontroldialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,11 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
564564

565565
void CoinControlDialog::changeEvent(QEvent* e)
566566
{
567-
#ifdef Q_OS_MACOS
568567
if (e->type() == QEvent::PaletteChange) {
569568
updateView();
570569
}
571-
#endif
570+
571+
QDialog::changeEvent(e);
572572
}
573573

574574
void CoinControlDialog::updateView()

src/qt/guiutil.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,11 +809,10 @@ void ThemedLabel::setThemedPixmap(const QString& image_filename, int width, int
809809

810810
void ThemedLabel::changeEvent(QEvent* e)
811811
{
812-
#ifdef Q_OS_MACOS
813812
if (e->type() == QEvent::PaletteChange) {
814813
updateThemedPixmap();
815814
}
816-
#endif
815+
817816
QLabel::changeEvent(e);
818817
}
819818

src/qt/overviewpage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,13 @@ void OverviewPage::setWalletModel(WalletModel *model)
297297

298298
void OverviewPage::changeEvent(QEvent* e)
299299
{
300-
#ifdef Q_OS_MACOS
301300
if (e->type() == QEvent::PaletteChange) {
302301
QIcon icon = m_platform_style->SingleColorIcon(QStringLiteral(":/icons/warning"));
303302
ui->labelTransactionsStatus->setIcon(icon);
304303
ui->labelWalletStatus->setIcon(icon);
305304
}
306-
#endif
305+
306+
QWidget::changeEvent(e);
307307
}
308308

309309
void OverviewPage::updateDisplayUnit()

src/qt/rpcconsole.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,6 @@ void RPCConsole::keyPressEvent(QKeyEvent *event)
882882

883883
void RPCConsole::changeEvent(QEvent* e)
884884
{
885-
#ifdef Q_OS_MACOS
886885
if (e->type() == QEvent::PaletteChange) {
887886
ui->clearButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
888887
ui->fontBiggerButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/fontbigger")));
@@ -896,7 +895,8 @@ void RPCConsole::changeEvent(QEvent* e)
896895
platformStyle->SingleColorImage(ICON_MAPPING[i].source).scaled(QSize(consoleFontSize * 2, consoleFontSize * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
897896
}
898897
}
899-
#endif
898+
899+
QWidget::changeEvent(e);
900900
}
901901

902902
void RPCConsole::message(int category, const QString &message, bool html)

src/qt/sendcoinsentry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,15 @@ void SendCoinsEntry::updateDisplayUnit()
238238

239239
void SendCoinsEntry::changeEvent(QEvent* e)
240240
{
241-
#ifdef Q_OS_MACOS
242241
if (e->type() == QEvent::PaletteChange) {
243242
ui->addressBookButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/address-book")));
244243
ui->pasteButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/editpaste")));
245244
ui->deleteButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
246245
ui->deleteButton_is->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
247246
ui->deleteButton_s->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
248247
}
249-
#endif
248+
249+
QStackedWidget::changeEvent(e);
250250
}
251251

252252
bool SendCoinsEntry::updateLabel(const QString &address)

src/qt/signverifymessagedialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ bool SignVerifyMessageDialog::eventFilter(QObject *object, QEvent *event)
286286

287287
void SignVerifyMessageDialog::changeEvent(QEvent* e)
288288
{
289-
#ifdef Q_OS_MACOS
290289
if (e->type() == QEvent::PaletteChange) {
291290
ui->addressBookButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/address-book")));
292291
ui->pasteButton_SM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/editpaste")));
@@ -297,5 +296,6 @@ void SignVerifyMessageDialog::changeEvent(QEvent* e)
297296
ui->verifyMessageButton_VM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/transaction_0")));
298297
ui->clearButton_VM->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
299298
}
300-
#endif
299+
300+
QDialog::changeEvent(e);
301301
}

src/qt/transactionview.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ void TransactionView::setModel(WalletModel *_model)
245245

246246
void TransactionView::changeEvent(QEvent* e)
247247
{
248-
#ifdef Q_OS_MACOS
249248
if (e->type() == QEvent::PaletteChange) {
250249
watchOnlyWidget->setItemIcon(
251250
TransactionFilterProxy::WatchOnlyFilter_Yes,
@@ -254,7 +253,8 @@ void TransactionView::changeEvent(QEvent* e)
254253
TransactionFilterProxy::WatchOnlyFilter_No,
255254
m_platform_style->SingleColorIcon(QStringLiteral(":/icons/eye_minus")));
256255
}
257-
#endif
256+
257+
QWidget::changeEvent(e);
258258
}
259259

260260
void TransactionView::chooseDate(int idx)

0 commit comments

Comments
 (0)