Trigger less QEvent::ApplicationPaletteChange

The event seems to be very expensive on certain platform theme plugins.

Fixes #1639
This commit is contained in:
q234rty 2023-12-16 18:04:15 +08:00
parent 021eed8388
commit d372158dde
No known key found for this signature in database
GPG key ID: D7E83C63C8CC4545
2 changed files with 8 additions and 0 deletions

View file

@ -201,9 +201,14 @@ NhekoFixupPaletteEventFilter::eventFilter(QObject *obj, QEvent *event)
// reason?!?
if (event->type() == QEvent::ChildAdded &&
obj->metaObject()->className() == QStringLiteral("QQuickRootItem")) {
QSet<QWindow *> 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;
}

View file

@ -45,6 +45,9 @@ public:
}
bool eventFilter(QObject *obj, QEvent *event) override;
private:
QSet<QWindow *> m_postedWindows;
};
class MainWindow : public QQuickView