From a0f0b4f65e96aecc9949d3089a283cdfaeefbb3b Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 11 Sep 2020 16:18:50 +0200 Subject: Support compile-time style selection By allowing importing styles without first importing QtQuick.Controls, which does runtime style selection. [ChangeLog][Styles] It's now possible to select a style at compile-time by importing that style explicitly instead of QtQuick.Controls. This avoids the need to do run-time style selection and hence deploy the QtQuick.Controls plugin with the application. Change-Id: I666d6dc7727fffd2c7b05743855f2086f076465a Fixes: QTBUG-86284 Reviewed-by: Ulf Hermann --- tests/auto/styleimports/tst_styleimports.cpp | 41 ---------------------------- 1 file changed, 41 deletions(-) (limited to 'tests/auto/styleimports/tst_styleimports.cpp') diff --git a/tests/auto/styleimports/tst_styleimports.cpp b/tests/auto/styleimports/tst_styleimports.cpp index 408f06c3..5e525b0f 100644 --- a/tests/auto/styleimports/tst_styleimports.cpp +++ b/tests/auto/styleimports/tst_styleimports.cpp @@ -61,9 +61,6 @@ private slots: void platformSelectors(); - void importStyleWithoutControls_data(); - void importStyleWithoutControls(); - void fallbackStyleShouldNotOverwriteTheme_data(); void fallbackStyleShouldNotOverwriteTheme(); }; @@ -208,44 +205,6 @@ void tst_StyleImports::platformSelectors() #endif } -void tst_StyleImports::importStyleWithoutControls_data() -{ - QTest::addColumn("style"); - - const auto builtInStyles = QQuickStylePrivate::builtInStyles(); - for (const auto &styleName : builtInStyles) - QTest::addRow(qPrintable(styleName)) << styleName; -} - -// Tests that warnings are printed when trying to import a specific style without first importing QtQuick.Controls. -void tst_StyleImports::importStyleWithoutControls() -{ - QFETCH(QString, style); - - QQmlApplicationEngine engine; - const QUrl url(testFileUrl(QString::fromLatin1("import%1StyleWithoutControls.qml").arg(style))); - bool success = false; - - // Account for extra warnings for fallback styles. - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("QtQuick.Controls must be imported before importing.*Basic")); - if (style == QLatin1String("macOS")) - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("QtQuick.Controls must be imported before importing.*Fusion")); - - // Account for the warning for the current style. - if (style != QLatin1String("Basic")) - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("QtQuick.Controls must be imported before importing.*" + style)); - - QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, - this, [url, &success](QObject *obj, const QUrl &objUrl) { - if (url == objUrl) - success = obj; - }, Qt::QueuedConnection); - - engine.load(url); - // It should load, but with warnings. - QTRY_VERIFY(success); -} - void tst_StyleImports::fallbackStyleShouldNotOverwriteTheme_data() { QTest::addColumn("style"); -- cgit v1.2.3