diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-05-07 15:46:11 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2020-05-15 18:46:39 +0200 |
commit | 9803ba9b6f74f5ac18220fe145fe1fe4c8f70910 (patch) | |
tree | 5e8ebce91c8d308bade5360f8affee7fa3092de8 /src/widgets/kernel/qapplication.cpp | |
parent | bd3b978701c32b2e13da853f2064aab369e32745 (diff) |
Deprecate QGuiApplication::paletteChanged() signal
Rather than have a paletteChanged() signal which can be connected to for
tracking when the application palette has changed, then it is better to
use the event that is sent to all windows and the application itself.
That way it is easy for a window/widget or item that cares about the
change to the application font to catch it in the event() function.
[ChangeLog][QtGui][QGuiApplication] Deprecated paletteChanged() signal
in favor of QEvent::ApplicationPaletteChanged.
Change-Id: I95da211e30590e357007cc14d8ee266baceba7b3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index f5d857b623..d7919c9414 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1211,18 +1211,15 @@ void QApplicationPrivate::handlePaletteChanged(const char *className) // Setting the global application palette is documented to // reset any previously set class specific widget palettes. - bool sendPaletteChangeToAllWidgets = false; - if (!className && !widgetPalettes.isEmpty()) { - sendPaletteChangeToAllWidgets = true; + if (!className && !widgetPalettes.isEmpty()) widgetPalettes.clear(); - } QGuiApplicationPrivate::handlePaletteChanged(className); QEvent event(QEvent::ApplicationPaletteChange); const QWidgetList widgets = QApplication::allWidgets(); for (auto widget : widgets) { - if (sendPaletteChangeToAllWidgets || (!className && widget->isWindow()) || (className && widget->inherits(className))) + if (!widget->isWindow() && widget->inherits(className)) QCoreApplication::sendEvent(widget, &event); } @@ -1734,7 +1731,8 @@ bool QApplication::event(QEvent *e) #endif } - if (e->type() == QEvent::LanguageChange || e->type() == QEvent::ApplicationFontChange) { + if (e->type() == QEvent::LanguageChange || e->type() == QEvent::ApplicationFontChange || + e->type() == QEvent::ApplicationPaletteChange) { // QGuiApplication::event does not account for the cases where // there is a top level widget without a window handle. So they // need to have the event posted here |