diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 1d7cd37f67..6602411798 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2643,7 +2643,9 @@ void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate:: QIconPrivate::clearIconCache(); - QStyleHintsPrivate::get(QGuiApplication::styleHints())->updateColorScheme(colorScheme()); + 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; @@ -2651,18 +2653,6 @@ void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate:: QGuiApplication::sendSpontaneousEvent(window, &themeChangeEvent); } -/*! - \internal - \brief QGuiApplicationPrivate::colorScheme - \return the platform theme's color scheme - or Qt::ColorScheme::Unknown if a platform theme cannot be established - */ -Qt::ColorScheme QGuiApplicationPrivate::colorScheme() -{ - return platformTheme() ? platformTheme()->colorScheme() - : Qt::ColorScheme::Unknown; -} - void QGuiApplicationPrivate::handleThemeChanged() { updatePalette(); diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 2bfcd87f3f..cca79534fc 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -323,8 +323,6 @@ public: static void updatePalette(); - static Qt::ColorScheme colorScheme(); - protected: virtual void handleThemeChanged(); diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index bbd70e8e7f..111a37ea2c 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -2127,8 +2127,9 @@ static void populateLightSystemBasePalette(QPalette &result) void QWindows11Style::polish(QPalette& pal) { Q_D(QWindows11Style); - highContrastTheme = QGuiApplicationPrivate::colorScheme() == Qt::ColorScheme::Unknown; - colorSchemeIndex = QGuiApplicationPrivate::colorScheme() == Qt::ColorScheme::Light ? 0 : 1; + + highContrastTheme = QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Unknown; + colorSchemeIndex = QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Light ? 0 : 1; if (!highContrastTheme && colorSchemeIndex == 0) populateLightSystemBasePalette(pal); diff --git a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp index 1df134b629..beee1d6f31 100644 --- a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp +++ b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp @@ -4755,7 +4755,7 @@ void QWindowsVistaStyle::polish(QPalette &pal) { Q_D(QWindowsVistaStyle); - if (QGuiApplicationPrivate::colorScheme() == Qt::ColorScheme::Dark) { + if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark) { // System runs in dark mode, but the Vista style cannot use a dark palette. // Overwrite with the light system palette. using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;