Skip to content

Commit fa18d28

Browse files
committed
qt: Make RPCConsole aware of runtime palette change
This change fixes the GUI when changing appearance on macOS.
1 parent f108382 commit fa18d28

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/qt/rpcconsole.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,25 @@ void RPCConsole::keyPressEvent(QKeyEvent *event)
817817
}
818818
}
819819

820+
void RPCConsole::changeEvent(QEvent* e)
821+
{
822+
#ifdef Q_OS_MACOS
823+
if (e->type() == QEvent::PaletteChange) {
824+
ui->clearButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/remove")));
825+
ui->fontBiggerButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/fontbigger")));
826+
ui->fontSmallerButton->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/fontsmaller")));
827+
ui->promptIcon->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/prompticon")));
828+
829+
for (int i = 0; ICON_MAPPING[i].url; ++i) {
830+
ui->messagesWidget->document()->addResource(
831+
QTextDocument::ImageResource,
832+
QUrl(ICON_MAPPING[i].url),
833+
platformStyle->SingleColorImage(ICON_MAPPING[i].source).scaled(QSize(consoleFontSize * 2, consoleFontSize * 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
834+
}
835+
}
836+
#endif
837+
}
838+
820839
void RPCConsole::message(int category, const QString &message, bool html)
821840
{
822841
QTime time = QTime::currentTime();

src/qt/rpcconsole.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class RPCConsole: public QWidget
7474
protected:
7575
virtual bool eventFilter(QObject* obj, QEvent *event) override;
7676
void keyPressEvent(QKeyEvent *) override;
77+
void changeEvent(QEvent* e) override;
7778

7879
private Q_SLOTS:
7980
void on_lineEdit_returnPressed();

0 commit comments

Comments
 (0)