diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-09-30 14:22:42 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-10-07 13:31:20 +0200 |
commit | 81e8cd67198768a08f5c65ec026e1553f78e1375 (patch) | |
tree | dccf23caaf08f06e3436e43993be8fa74093a1d0 /src/quickcontrols2 | |
parent | 8b534487044dfb3b464431ecb91ef4e0864af4ed (diff) |
Make tests explicitly use Basic where necessary
The previous commit changes the how the default style is set, and since
the tests all assumed that Basic was the default, we now need to
ensure it is explicitly set.
If we want to, we can revert this patch (or file-by-file) later and
ensure that these tests work with all styles. For now, just keep things
working as they used to.
Tests that use QTEST_QUICKCONTROLS_MAIN are not changed, as they
already run with all built-in styles.
Tests that don't use types that will cause issues,
like tst_qquickcolor, do not need to be changed.
tst_snippets can be run manually to produce screenshots, so we specify its
style in a qtquickcontrols2.conf file to allow it to be overridden by e.g.
application arguments (QQuickStyle::setStyle() takes precedence over all
other approaches of setting a style).
Change-Id: Ifae7e959f89a41a757c170272038fad139bba04f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r-- | src/quickcontrols2/qquickstyle.cpp | 5 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyle_p.h | 1 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin.cpp | 4 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index 5b45a98a..7ad4a38d 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -260,6 +260,11 @@ struct QQuickStyleSpec Q_GLOBAL_STATIC(QQuickStyleSpec, styleSpec) +QString QQuickStylePrivate::style() +{ + return styleSpec()->style; +} + QString QQuickStylePrivate::effectiveStyleName(const QString &styleName) { return !styleName.isEmpty() ? styleName : QLatin1String("Basic"); diff --git a/src/quickcontrols2/qquickstyle_p.h b/src/quickcontrols2/qquickstyle_p.h index e2db35d7..8d0e5a8d 100644 --- a/src/quickcontrols2/qquickstyle_p.h +++ b/src/quickcontrols2/qquickstyle_p.h @@ -58,6 +58,7 @@ class QSettings; class Q_QUICKCONTROLS2_EXPORT QQuickStylePrivate { public: + static QString style(); static QString effectiveStyleName(const QString &styleName); static QString fallbackStyle(); static bool isCustomStyle(); diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp index 730a8423..27299b21 100644 --- a/src/quickcontrols2/qquickstyleplugin.cpp +++ b/src/quickcontrols2/qquickstyleplugin.cpp @@ -63,7 +63,9 @@ void QQuickStylePlugin::registerTypes(const char *uri) qCDebug(lcStylePlugin).nospace() << "registerTypes called with uri " << uri << "; plugin name is " << name(); const QTypeRevision latestControlsRevision = QQmlMetaType::latestModuleVersion(QLatin1String("QtQuick.Controls")); - QString styleName = QQuickStyle::name(); + // Use the private function because we don't want to cause resolve() to be called, + // as the logic that assigns a default style if one wasn't set would interfere with compile-time style selection. + QString styleName = QQuickStylePrivate::style(); if (!latestControlsRevision.isValid() && styleName.isEmpty()) { // The user hasn't imported QtQuick.Controls, nor set a style via the runtime methods. qCDebug(lcStylePlugin).nospace() << uri << " imported before QtQuick.Controls; using compile-time style selection"; |