Remove QGuiApplicationPrivate::colorScheme()

Use the platform theme or QStyleHints instead.

Task-number: QTBUG-124490
Change-Id: Iab12faa726d3031d6a250664468dac333c2c2e0c
Reviewed-by: Doris Verria <doris.verria@qt.io>
bb10
Volker Hilsheimer 2024-04-30 14:06:57 +02:00
parent e176dd78fd
commit 8bc80f2e1a
4 changed files with 7 additions and 18 deletions

View File

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

View File

@ -323,8 +323,6 @@ public:
static void updatePalette();
static Qt::ColorScheme colorScheme();
protected:
virtual void handleThemeChanged();

View File

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

View File

@ -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;