diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-11-30 09:43:37 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-11-30 18:53:31 +0000 |
commit | 4e97364bc0dbb8826d079bd9f11ee4ffaf045ad8 (patch) | |
tree | 71c08a48aaa4be9c48e5b4d58678a6cd5ae603d6 | |
parent | 5be2c864c32e65dcde50d2b8b29f0dfdae0128de (diff) |
gallery: don't store QQuickStyle::name() in settings on startup
It's no longer empty if not specified, so just skip that step
altogether. Add the desktop styles to the list of selectable styles,
but only on the correct platforms. Only set the style at startup if it
wasn't specified via QT_QUICK_CONTROLS_STYLE. I tried to detect if a
-style application argument was passed, but it doesn't show up in the
list of arguments.
Change-Id: I7c216372580a012693b7a01d138d79c8d46afe66
Fixes: QTBUG-88955
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 71249db0cb5feed40410486bcc4747abcf4f1ed9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | examples/quickcontrols2/gallery/gallery.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/quickcontrols2/gallery/gallery.cpp b/examples/quickcontrols2/gallery/gallery.cpp index 5c7dc188..82706d53 100644 --- a/examples/quickcontrols2/gallery/gallery.cpp +++ b/examples/quickcontrols2/gallery/gallery.cpp @@ -65,16 +65,18 @@ int main(int argc, char *argv[]) QIcon::setThemeName("gallery"); QSettings settings; - QString style = QQuickStyle::name(); - if (!style.isEmpty()) - settings.setValue("style", style); - else + if (qgetenv("QT_QUICK_CONTROLS_STYLE").isEmpty()) QQuickStyle::setStyle(settings.value("style").toString()); QQmlApplicationEngine engine; - const QStringList builtInStyles = { QLatin1String("Basic"), QLatin1String("Fusion"), + QStringList builtInStyles = { QLatin1String("Basic"), QLatin1String("Fusion"), QLatin1String("Imagine"), QLatin1String("Material"), QLatin1String("Universal") }; +#if defined(Q_OS_MACOS) + builtInStyles << QLatin1String("macOS"); +#elif defined(Q_OS_WINDOWS) + builtInStyles << QLatin1String("Windows"); +#endif engine.rootContext()->setContextProperty("builtInStyles", builtInStyles); engine.load(QUrl("qrc:/gallery.qml")); |