summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-06-05 00:18:17 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-06-08 22:32:14 +0200
commit8485e7ae81cd75b31af755e54dd7e61c1dc34574 (patch)
tree1d97533a4e7072afff50b623013739b27319a413 /src
parentRemove MacExtras include (diff)
downloadnheko-8485e7ae81cd75b31af755e54dd7e61c1dc34574.tar.xz
Workaround palette not set on new windows
Diffstat (limited to 'src')
-rw-r--r--src/MainWindow.cpp14
-rw-r--r--src/MainWindow.h13
-rw-r--r--src/main.cpp3
3 files changed, 30 insertions, 0 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 63f20752..51b23e0f 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 543b0f69..0a5f9433 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 951d53f0..da67ca43 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