diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-10-06 00:11:25 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-10-25 07:20:59 +0000 |
commit | 32810acaa191ba00be5aac5d771c23b87628292c (patch) | |
tree | 0c45b6ab2da561612032aa66a542cb89b9128b5a /tests/auto/qquickstyle/tst_qquickstyle.cpp | |
parent | 6ba40b132562593781ceffc13f642d366d6ad672 (diff) |
Let specifying the fallback style for custom styles
For example, you can call QQuickStyle::setStyle(":/mycontrols") and
QQuickStyle::setFallbackStyle("Material") to select a custom style so
that the missing files will fallback to the Material style.
Notice that the Material and Universal styles do not contain all files.
For example, the non-visual Control.qml, Container.qml are not duplicated.
For these, we must fallback to the Default style that is guaranteed to
contain them all.
[ChangeLog][Controls] Added support for specifying the fallback style for
custom styles via :/qtquickcontrols2.conf, QT_QUICK_CONTROLS_FALLBACK_STYLE
or QQuickStyle::setFallbackStyle().
Change-Id: I00be1c8c6aaca875ef851c90d018e9b5e2f501b7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/qquickstyle/tst_qquickstyle.cpp')
-rw-r--r-- | tests/auto/qquickstyle/tst_qquickstyle.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp index 11ff58e7..15edc67b 100644 --- a/tests/auto/qquickstyle/tst_qquickstyle.cpp +++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp @@ -38,15 +38,28 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtQuickControls2/qquickstyle.h> +#include <QtQuickControls2/private/qquickstyle_p.h> +#include <QtGui/private/qguiapplication_p.h> class tst_QQuickStyle : public QObject { Q_OBJECT private slots: + void init(); void lookup(); + void commandLineArgument(); + void environmentVariables(); }; +void tst_QQuickStyle::init() +{ + QQuickStylePrivate::reset(); + QGuiApplicationPrivate::styleOverride.clear(); + qunsetenv("QT_QUICK_CONTROLS_STYLE"); + qunsetenv("QT_QUICK_CONTROLS_FALLBACK_STYLE"); +} + void tst_QQuickStyle::lookup() { QVERIFY(QQuickStyle::name().isEmpty()); @@ -67,6 +80,20 @@ void tst_QQuickStyle::lookup() QVERIFY(!QQuickStyle::path().isEmpty()); } +void tst_QQuickStyle::commandLineArgument() +{ + QGuiApplicationPrivate::styleOverride = "CmdLineArgStyle"; + QCOMPARE(QQuickStyle::name(), QString("CmdLineArgStyle")); +} + +void tst_QQuickStyle::environmentVariables() +{ + qputenv("QT_QUICK_CONTROLS_STYLE", "EnvVarStyle"); + qputenv("QT_QUICK_CONTROLS_FALLBACK_STYLE", "EnvVarFallbackStyle"); + QCOMPARE(QQuickStyle::name(), QString("EnvVarStyle")); + QCOMPARE(QQuickStylePrivate::fallbackStyle(), QString("EnvVarFallbackStyle")); +} + QTEST_MAIN(tst_QQuickStyle) #include "tst_qquickstyle.moc" |