diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2021-01-11 17:36:30 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2021-01-13 11:33:07 +0100 |
commit | 4b66c0bd7de6063982459fe45f69278fd0519b1b (patch) | |
tree | f460843770617b2a08d4cf586be70778c6e3a22b /src/quickcontrols2 | |
parent | 023a03e9c5d2e714b676df0c89e90f3057be52e4 (diff) |
Ensure that C++ Qt Quick tests are run with all applicable styles
Since 8b534487044dfb3b464431ecb91ef4e0864af4ed, the C++ tests were only
being run with the default style for the platform that they were run
on.
Fix this by keeping track of whether a default style is in use and
checking it in the tests.
Pick-to: 6.0
Change-Id: I4ddd90aba12ede83fff0d3d1002534e79fce8c87
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r-- | src/quickcontrols2/qquickstyle.cpp | 16 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyle_p.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index f4e1da00..7c403529 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -184,7 +184,10 @@ struct QQuickStyleSpec // Find the config file. resolveConfigFilePath(); + usingDefaultStyle = false; + if (style.isEmpty() || style.toLower() == QStringLiteral("default")) { + usingDefaultStyle = true; style.clear(); qCDebug(lcQtQuickControlsStyle) << "no style (or Default) was specified;" @@ -226,6 +229,7 @@ struct QQuickStyleSpec custom = false; resolved = false; + usingDefaultStyle = false; style.clear(); fallbackStyle.clear(); fallbackMethod.clear(); @@ -250,6 +254,8 @@ struct QQuickStyleSpec bool custom = false; // Have we resolved the style yet? bool resolved = false; + // Are we using the default style for this platform (because no style was specified)? + bool usingDefaultStyle = false; // The name of the style. QString style; // The built-in style to use if the requested style cannot be found. @@ -262,6 +268,11 @@ struct QQuickStyleSpec Q_GLOBAL_STATIC(QQuickStyleSpec, styleSpec) +/* + Note that most of these functions (with the exception of e.g. isResolved()) + should not be called before the style has been resolved, as it's only after + that happens that they will have been set. +*/ QString QQuickStylePrivate::style() { return styleSpec()->style; @@ -287,6 +298,11 @@ bool QQuickStylePrivate::isResolved() return styleSpec()->resolved; } +bool QQuickStylePrivate::isUsingDefaultStyle() +{ + return styleSpec()->usingDefaultStyle; +} + void QQuickStylePrivate::init() { QQuickStyleSpec *spec = styleSpec(); diff --git a/src/quickcontrols2/qquickstyle_p.h b/src/quickcontrols2/qquickstyle_p.h index 8d0e5a8d..31c70893 100644 --- a/src/quickcontrols2/qquickstyle_p.h +++ b/src/quickcontrols2/qquickstyle_p.h @@ -63,6 +63,7 @@ public: static QString fallbackStyle(); static bool isCustomStyle(); static bool isResolved(); + static bool isUsingDefaultStyle(); static bool exists(); static void init(); static void reset(); |