diff options
Diffstat (limited to 'src/quickcontrols2/qquickstyle.cpp')
-rw-r--r-- | src/quickcontrols2/qquickstyle.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index 7c4035298f..3ba0ad0610 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -192,6 +192,9 @@ struct QQuickStyleSpec qCDebug(lcQtQuickControlsStyle) << "no style (or Default) was specified;" << "checking if we have an appropriate style for this platform"; + + // If these defaults are changed, ensure that the "Using Styles in Qt Quick Controls" + // section of qtquickcontrols2-styles.qdoc is updated. #if defined(Q_OS_MACOS) style = QLatin1String("macOS"); #elif defined(Q_OS_WINDOWS) @@ -410,20 +413,13 @@ const QPalette *QQuickStylePrivate::readPalette(const QSharedPointer<QSettings> } #endif // QT_CONFIG(settings) -static bool qt_is_dark_system_theme() -{ - if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { - if (const QPalette *systemPalette = theme->palette(QPlatformTheme::SystemPalette)) { - const QColor &textColor = systemPalette->color(QPalette::WindowText); - return textColor.red() > 128 && textColor.blue() > 128 && textColor.green() > 128; - } - } - return false; -} - bool QQuickStylePrivate::isDarkSystemTheme() { - static bool dark = qt_is_dark_system_theme(); + const static bool dark = [](){ + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + return theme->appearance() == QPlatformTheme::Appearance::Dark; + return false; + }(); return dark; } |