Update QStyleHints::colorScheme before updating palettes

The code polshing palettes needs to be able to rely on an updated
value of the color scheme as reported by the QStyleHints, otherwise
styles might apply the incorrect polishing logic.

Update the style hints as part of processing theme change handling,
and do it as the first thing, before updating the palette.

Pick-to: 6.7
Task-number: QTBUG-124490
Change-Id: I393faa57ecfa6da94497ae93a4e8b5d2782ec42a
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
bb10
Volker Hilsheimer 2024-04-30 13:53:20 +02:00
parent 8bc80f2e1a
commit b5215f65c0
1 changed files with 4 additions and 4 deletions

View File

@ -2643,10 +2643,6 @@ void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::
QIconPrivate::clearIconCache();
const auto newColorScheme = platformTheme() ? platformTheme()->colorScheme()
: Qt::ColorScheme::Unknown;
QStyleHintsPrivate::get(QGuiApplication::styleHints())->updateColorScheme(newColorScheme);
QEvent themeChangeEvent(QEvent::ThemeChange);
const QWindowList windows = tce->window ? QWindowList{tce->window} : window_list;
for (auto *window : windows)
@ -2655,6 +2651,10 @@ void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::
void QGuiApplicationPrivate::handleThemeChanged()
{
const auto newColorScheme = platformTheme() ? platformTheme()->colorScheme()
: Qt::ColorScheme::Unknown;
QStyleHintsPrivate::get(QGuiApplication::styleHints())->updateColorScheme(newColorScheme);
updatePalette();
QIconLoader::instance()->updateSystemTheme();