diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 636956aafa6..444091afefa 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1531,7 +1531,7 @@ void QGuiApplicationPrivate::createPlatformIntegration() init_platform(QLatin1StringView(platformName), platformPluginPath, platformThemeName, argc, argv); if (const QPlatformTheme *theme = platformTheme()) - QStyleHintsPrivate::get(QGuiApplication::styleHints())->setColorScheme(theme->colorScheme()); + QStyleHintsPrivate::get(QGuiApplication::styleHints())->updateColorScheme(theme->colorScheme()); if (!icon.isEmpty()) forcedWindowIcon = QDir::isAbsolutePath(icon) ? QIcon(icon) : QIcon::fromTheme(icon); @@ -2643,7 +2643,7 @@ void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate:: QIconPrivate::clearIconCache(); - QStyleHintsPrivate::get(QGuiApplication::styleHints())->setColorScheme(colorScheme()); + QStyleHintsPrivate::get(QGuiApplication::styleHints())->updateColorScheme(colorScheme()); QEvent themeChangeEvent(QEvent::ThemeChange); const QWindowList windows = tce->window ? QWindowList{tce->window} : window_list; diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 5becae76c6a..5029701f246 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -595,11 +595,15 @@ int QStyleHints::mouseQuickSelectionThreshold() const /*! \internal - QStyleHintsPrivate::setColorScheme - set a new color scheme. + QStyleHintsPrivate::updateColorScheme - set a new color scheme. + + This function is called by the QPA plugin when the system theme changes. This in + turn might be the result of an explicit request of a color scheme via setColorScheme. + Set \a colorScheme as the new color scheme of the QStyleHints. The colorSchemeChanged signal will be emitted if present and new color scheme differ. */ -void QStyleHintsPrivate::setColorScheme(Qt::ColorScheme colorScheme) +void QStyleHintsPrivate::updateColorScheme(Qt::ColorScheme colorScheme) { if (m_colorScheme == colorScheme) return; diff --git a/src/gui/kernel/qstylehints_p.h b/src/gui/kernel/qstylehints_p.h index c58386d7a31..2b3979512a1 100644 --- a/src/gui/kernel/qstylehints_p.h +++ b/src/gui/kernel/qstylehints_p.h @@ -41,7 +41,7 @@ public: int m_touchDoubleTapDistance = -1; Qt::ColorScheme colorScheme() const { return m_colorScheme; } - void setColorScheme(Qt::ColorScheme colorScheme); + void updateColorScheme(Qt::ColorScheme colorScheme); static QStyleHintsPrivate *get(QStyleHints *q); diff --git a/src/gui/platform/unix/qgenericunixthemes.cpp b/src/gui/platform/unix/qgenericunixthemes.cpp index ce729a74a3a..fc4b2296d26 100644 --- a/src/gui/platform/unix/qgenericunixthemes.cpp +++ b/src/gui/platform/unix/qgenericunixthemes.cpp @@ -957,7 +957,7 @@ Qt::ColorScheme QKdeTheme::colorScheme() const /*! \internal - \brief QKdeTheme::setColorScheme - guess and set appearance for unix themes. + \brief QKdeTheme::updateColorScheme - guess and set appearance for unix themes. KDE themes do not have an appearance property. The key words "dark" or "light" should be part of the theme name. This is, however, not a mandatory convention. diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 206bbd03d66..0de83ccb28b 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -703,7 +703,7 @@ Q_DECLARE_JNI_NATIVE_METHOD(handleScreenRemoved) static void handleUiDarkModeChanged(JNIEnv */*env*/, jobject /*thiz*/, jint newUiMode) { - QAndroidPlatformIntegration::setColorScheme( + QAndroidPlatformIntegration::updateColorScheme( (newUiMode == 1 ) ? Qt::ColorScheme::Dark : Qt::ColorScheme::Light); } Q_DECLARE_JNI_NATIVE_METHOD(handleUiDarkModeChanged) diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 038fe5172a7..4d9e6fa7045 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -537,7 +537,7 @@ void QAndroidPlatformIntegration::setScreenSize(int width, int height) Qt::ColorScheme QAndroidPlatformIntegration::m_colorScheme = Qt::ColorScheme::Light; -void QAndroidPlatformIntegration::setColorScheme(Qt::ColorScheme colorScheme) +void QAndroidPlatformIntegration::updateColorScheme(Qt::ColorScheme colorScheme) { if (m_colorScheme == colorScheme) return; diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index 5f1126fafc9..b7bfb58d1dd 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -110,7 +110,7 @@ public: void flushPendingUpdates(); - static void setColorScheme(Qt::ColorScheme colorScheme); + static void updateColorScheme(Qt::ColorScheme colorScheme); static Qt::ColorScheme colorScheme() { return m_colorScheme; } #if QT_CONFIG(vulkan) QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override;