From bc2ed77a72cbcafecb6954ffa8703cbb5335490a Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 3 Oct 2024 04:44:39 +0400 Subject: [PATCH] Send QEvent::ThemeChange to QGuiApplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently it's sent only to all windows. This is inconvenient when trying to use it with something that is not attached to a window, e.g. a tray icon. Change-Id: I774ee93918715a58f686e4f21ae7cdf2217ab5ab Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 0d9749eec2c..0f531cb280d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2079,6 +2079,10 @@ bool QGuiApplication::event(QEvent *e) postEvent(topLevelWindow, new QEvent(e->type())); } break; + case QEvent::ThemeChange: + for (auto *w : QGuiApplication::allWindows()) + forwardEvent(w, e); + break; case QEvent::Quit: // Close open windows. This is done in order to deliver de-expose // events while the event loop is still running. @@ -2795,9 +2799,10 @@ void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate:: QIconPrivate::clearIconCache(); QEvent themeChangeEvent(QEvent::ThemeChange); - const QWindowList windows = tce->window ? QWindowList{tce->window} : window_list; - for (auto *window : windows) - QGuiApplication::sendSpontaneousEvent(window, &themeChangeEvent); + if (tce->window) + QGuiApplication::sendSpontaneousEvent(tce->window, &themeChangeEvent); + else + QGuiApplication::sendSpontaneousEvent(qGuiApp, &themeChangeEvent); } void QGuiApplicationPrivate::handleThemeChanged()