diff options
Diffstat (limited to 'src/imports/controls/universal/qquickuniversalstyle.cpp')
-rw-r--r-- | src/imports/controls/universal/qquickuniversalstyle.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/imports/controls/universal/qquickuniversalstyle.cpp b/src/imports/controls/universal/qquickuniversalstyle.cpp index 2328f1a5..b33c27e8 100644 --- a/src/imports/controls/universal/qquickuniversalstyle.cpp +++ b/src/imports/controls/universal/qquickuniversalstyle.cpp @@ -132,6 +132,15 @@ static QRgb qquickuniversal_accent_color(QQuickUniversalStyle::Color accent) return colors[accent]; } +extern bool qt_is_dark_system_theme(); + +static QQuickUniversalStyle::Theme qquickuniversal_effective_theme(QQuickUniversalStyle::Theme theme) +{ + if (theme == QQuickUniversalStyle::System) + theme = qt_is_dark_system_theme() ? QQuickUniversalStyle::Dark : QQuickUniversalStyle::Light; + return theme; +} + // If no value was inherited from a parent or explicitly set, the "global" values are used. // The initial, default values of the globals are hard-coded here, but the environment // variables and .conf file override them if specified. @@ -164,6 +173,7 @@ QQuickUniversalStyle::Theme QQuickUniversalStyle::theme() const void QQuickUniversalStyle::setTheme(Theme theme) { + theme = qquickuniversal_effective_theme(theme); m_explicitTheme = true; if (m_theme == theme) return; @@ -536,7 +546,7 @@ void QQuickUniversalStyle::init() QByteArray themeValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_THEME", settings, QStringLiteral("Theme")); Theme themeEnum = toEnumValue<Theme>(themeValue, &ok); if (ok) - GlobalTheme = m_theme = themeEnum; + GlobalTheme = m_theme = qquickuniversal_effective_theme(themeEnum); else if (!themeValue.isEmpty()) qWarning().nospace().noquote() << "Universal: unknown theme value: " << themeValue; |