From d372158dde5161d1fa2ad1e8d8026f7906d369f3 Mon Sep 17 00:00:00 2001 From: q234rty Date: Sat, 16 Dec 2023 18:04:15 +0800 Subject: [PATCH] Trigger less QEvent::ApplicationPaletteChange The event seems to be very expensive on certain platform theme plugins. Fixes #1639 --- src/MainWindow.cpp | 5 +++++ src/MainWindow.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index b7834cba..a4a0eff0 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -201,9 +201,14 @@ NhekoFixupPaletteEventFilter::eventFilter(QObject *obj, QEvent *event) // reason?!? if (event->type() == QEvent::ChildAdded && obj->metaObject()->className() == QStringLiteral("QQuickRootItem")) { + QSet newWindows; for (const auto window : QGuiApplication::topLevelWindows()) { + newWindows.insert(window); + if (m_postedWindows.contains(window)) + continue; QGuiApplication::postEvent(window, new QEvent(QEvent::ApplicationPaletteChange)); } + m_postedWindows.swap(newWindows); } return false; } diff --git a/src/MainWindow.h b/src/MainWindow.h index c493b5b2..928446aa 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -45,6 +45,9 @@ public: } bool eventFilter(QObject *obj, QEvent *event) override; + +private: + QSet m_postedWindows; }; class MainWindow : public QQuickView