summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2024-04-19 10:41:01 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2024-04-23 16:44:26 +0200
commiteee575595b11f4c2621a71ad89fcfde3b204e59f (patch)
treefebe0a1967c542ed1e3e5fb0f00cb808d6b09ec0 /src/gui/kernel
parentc1f1523047b2e005fb7442847c2aa000faa7d0ac (diff)
ColorScheme: clean up code to prepare adding a setter
The current QStyleHintsPrivate::setColorScheme is called when the system theme changes, handling the change and informing the application. It is not a setter. When we add a public setter, that setter will have to go through the QPlatformTheme to request an override for the application. That will then result in a call back to the QStyleHints to update the theme with the effective color scheme (or ignore the request for the override, on some platforms). Rename it (and similar misleading APIs in platform plugins) to updateColorScheme, and adjust outdated comments in some of the platform plugins. Task-number: QTBUG-124490 Change-Id: I6a852211254993df86acf2e2d42cf345e7401f4f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qguiapplication.cpp4
-rw-r--r--src/gui/kernel/qstylehints.cpp8
-rw-r--r--src/gui/kernel/qstylehints_p.h2
3 files changed, 9 insertions, 5 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 636956aafa..444091afef 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 5becae76c6..5029701f24 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 c58386d7a3..2b3979512a 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);