diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-09-08 17:33:17 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-10-07 13:31:10 +0200 |
commit | 8b534487044dfb3b464431ecb91ef4e0864af4ed (patch) | |
tree | c801af7dc290a1108764bc54659ab2e417bb9cef /src | |
parent | 280b7526d41244912ce89d3be1e3d47329453658 (diff) |
Default to the most appropriate built-in style if none is specified
[ChangeLog][Styles] An appropriate built-in style is now used as the
default style if one is available for the target platform. For example,
when running a Qt Quick Controls application on macOS, the macOS style
will be used. On Android, the Material style will be used. When running
on e.g. an embedded device, where no native style is available, use the
Basic (formerly "Default") style.
Change-Id: Ie61d1a8a1a83fbeba63387c7ca3671084f47bc04
Fixes: QTBUG-86403
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quickcontrols2/qquickstyle.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index ca844c6f..5b45a98a 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -184,6 +184,27 @@ struct QQuickStyleSpec // Find the config file. resolveConfigFilePath(); + if (style.isEmpty()) { + qCDebug(lcQtQuickControlsStyle) << "no style was specified; checking if we have an appropriate style for this platform"; +#if defined(Q_OS_MACOS) + style = QLatin1String("macOS"); +// TODO: Enable this section when the windows style is complete: QTBUG-86399 +//#elif defined(Q_OS_WINDOWS) +// style = QLatin1String("Windows"); +#elif defined(Q_OS_ANDROID) + style = QLatin1String("Material"); +#elif defined(QT_OS_LINUX) + style = QLatin1String("Fusion"); +#endif + if (!style.isEmpty()) + qCDebug(lcQtQuickControlsStyle) << "using" << style << "as a default"; + else + qCDebug(lcQtQuickControlsStyle) << "no appropriate style found; using Basic as a default"; + } + + // If it's still empty by this point, then it means we have no native style available for this platform, + // as is the case on e.g. embedded. In that case, we want to default to the Basic style, + // which is what effectiveStyleName() returns when "style" is empty. custom = !builtInStyleList.contains(QQuickStylePrivate::effectiveStyleName(style)); resolved = true; |