Send QEvent::ThemeChange to QGuiApplication

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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
Ilya Fedin 2024-10-03 04:44:39 +04:00
parent c0e07cc3e2
commit bc2ed77a72

View File

@ -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()