From: Stephan Witt Date: Wed, 5 Jan 2022 07:26:18 +0000 (+0100) Subject: #12451 Adjust color cache on change of dark/light mode X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d9b9307d14ea5cdf6e6e17d2ccba15048407a3cb;p=features.git #12451 Adjust color cache on change of dark/light mode --- diff --git a/src/frontends/qt/GuiApplication.cpp b/src/frontends/qt/GuiApplication.cpp index 5cd8f290d4..b44f2c56b2 100644 --- a/src/frontends/qt/GuiApplication.cpp +++ b/src/frontends/qt/GuiApplication.cpp @@ -2322,6 +2322,12 @@ void GuiApplication::onLocaleChanged() } +void GuiApplication::onPaletteChanged() +{ + colorCache().setPalette(palette()); +} + + void GuiApplication::handleKeyFunc(FuncCode action) { char_type c = 0; @@ -2977,6 +2983,11 @@ bool GuiApplication::event(QEvent * e) e->accept(); return true; #endif + case QEvent::ApplicationPaletteChange: { + // runtime switch from/to dark mode + onPaletteChanged(); + return QApplication::event(e); + } default: return QApplication::event(e); } diff --git a/src/frontends/qt/GuiApplication.h b/src/frontends/qt/GuiApplication.h index f0c3e1ea75..e40815e8be 100644 --- a/src/frontends/qt/GuiApplication.h +++ b/src/frontends/qt/GuiApplication.h @@ -230,6 +230,8 @@ private Q_SLOTS: /// void onLocaleChanged(); /// + void onPaletteChanged(); + /// void slotProcessFuncRequestQueue() { processFuncRequestQueue(); } /// #if (QT_VERSION >= 0x050100)