diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 63f20752c5f633d3a12f45e5fba1f776e09bd215..51b23e0f48a2b651078e90fd94fdf29861852655 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -376,6 +376,20 @@ MainWindow::showChatPage() emit switchToChatPage(); } +bool +NhekoFixupPaletteEventFilter::eventFilter(QObject *obj, QEvent *event) +{ + // Workaround for the QGuiApplication palette not being applied to toplevel windows for some + // reason?!? + if (event->type() == QEvent::ChildAdded && + obj->metaObject()->className() == QStringLiteral("QQuickRootItem")) { + for (const auto window : QGuiApplication::topLevelWindows()) { + QGuiApplication::postEvent(window, new QEvent(QEvent::ApplicationPaletteChange)); + } + } + return false; +} + void MainWindow::closeEvent(QCloseEvent *event) { diff --git a/src/MainWindow.h b/src/MainWindow.h index 543b0f69a18fac8437bf58999387e74c54cb28aa..0a5f94335299f040d16fe66632824b6b108692db 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -37,6 +37,19 @@ class MemberList; class ReCaptcha; } +class NhekoFixupPaletteEventFilter final : public QObject +{ + Q_OBJECT + +public: + NhekoFixupPaletteEventFilter(QObject *parent) + : QObject(parent) + { + } + + bool eventFilter(QObject *obj, QEvent *event) override; +}; + class MainWindow final : public QQuickView { Q_OBJECT diff --git a/src/main.cpp b/src/main.cpp index 951d53f09f3535a94d489d0f9870b46bdc7e6555..da67ca438cd8a64a74c420152ccf45e0550ef46f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -309,6 +309,9 @@ main(int argc, char *argv[]) std::exit(1); } + auto filter = new NhekoFixupPaletteEventFilter(&app); + app.installEventFilter(filter); + if (parser.isSet(configName)) UserSettings::initialize(parser.value(configName)); else