diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-11-30 09:43:37 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-11-30 15:12:47 +0100 |
commit | 71249db0cb5feed40410486bcc4747abcf4f1ed9 (patch) | |
tree | fe906610af61e5d9c59b126e21e39cbd8adf1a02 | |
parent | 01851825f7a823c418cadbaccf78d32fc4440b49 (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
Pick-to: 6.0 6.0.0
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-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")); |