aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2020-04-02 11:51:21 +0200
committerMitch Curtis <mitch.curtis@qt.io>2020-08-26 11:45:48 +0200
commitef771a0fd70f05d7204fb8cbd8789aa1ed6eff4b (patch)
treea42ee55e8bf0c1af8d69f1578945229eb7790c25
parent2ba4a895a48be6927818008580ab0a88cc8c4e12 (diff)
Stop using resolvedUrl() to resolve QML files
This is necessary to move away from imperative type registration of QML files (i.e. qmlRegisterType()). A later patch will use qmlRegisterModuleImport() to register the QtQuick.Controls import with the style set by the user, which will require each style to have a qmldir listing the files that it provides. Note that some plugins still register QML files, but these registrations will have to stay for now until we can split out "impl" plugins in later patches where those files can be registered. tst_qquickstyleselector will be added back in some other form in a follow-up patch. Task-number: QTBUG-82922 Change-Id: I8182533d9912ed493efda6eb91c69fc064af07ee Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc3
-rw-r--r--src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp1
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp109
-rw-r--r--src/quickcontrols2/qquickstyleplugin.cpp42
-rw-r--r--src/quickcontrols2/qquickstyleplugin_p.h6
-rw-r--r--src/quickcontrols2/qquickstyleselector.cpp163
-rw-r--r--src/quickcontrols2/qquickstyleselector_p.h86
-rw-r--r--src/quickcontrols2/qquickstyleselector_p_p.h70
-rw-r--r--src/quickcontrols2/quickcontrols2.pri7
-rw-r--r--tests/auto/auto.pro1
-rw-r--r--tests/auto/qquickstyleselector/CMakeLists.txt61
-rw-r--r--tests/auto/qquickstyleselector/ResourceStyle/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/Control.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/Label.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/PlatformStyle/+linux/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/PlatformStyle/+macos/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/PlatformStyle/+windows/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/data/PlatformStyle/Button.qml2
-rw-r--r--tests/auto/qquickstyleselector/qquickstyleselector.pro19
-rw-r--r--tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp167
24 files changed, 36 insertions, 721 deletions
diff --git a/src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc
index d73d1abe..adda3b15 100644
--- a/src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc
+++ b/src/imports/controls/doc/src/qtquickcontrols2-fileselectors.qdoc
@@ -40,8 +40,7 @@
can assume the context, that is, a specific style. This typically leads
to some code duplication, but on the other hand, cuts the aforementioned
hard dependency to the style, and leads to simpler and more efficient
- QML code. The same technique is used to implement the \l {Styling Qt
- Quick Controls}{Qt Quick Controls styles}.
+ QML code.
The following example demonstrates a custom rounded button that has a
styled drop shadow in the \l {Material Style}{Material style}, and looks
diff --git a/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp b/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp
index d8cc04dd..88f6cd1e 100644
--- a/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp
+++ b/src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp
@@ -42,7 +42,6 @@
#include "qquickmaterialprogressbar_p.h"
#include "qquickmaterialripple_p.h"
-#include <QtQuickControls2/private/qquickstyleselector_p.h>
#include <QtQuickControls2/private/qquickpaddedrectangle_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index 53868d16..38fba04e 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -78,6 +78,7 @@ public:
QtQuickControls2Plugin(QObject *parent = nullptr);
~QtQuickControls2Plugin();
+ void initializeEngine(QQmlEngine *engine, const char *uri) override;
void registerTypes(const char *uri) override;
void unregisterTypes() override;
@@ -85,6 +86,8 @@ public:
void initializeTheme(QQuickTheme *theme) override;
private:
+ void init();
+
QList<QQuickStylePlugin *> loadStylePlugins();
QQuickTheme *createTheme(const QString &name);
};
@@ -99,6 +102,12 @@ QtQuickControls2Plugin::~QtQuickControls2Plugin()
// initialization and cleanup, as plugins are not unloaded on macOS.
}
+void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *uri)
+{
+ QQuickStylePlugin::initializeEngine(engine, uri);
+ init();
+}
+
static bool isDefaultStyle(const QString &style)
{
return style.isEmpty() || style.compare(QStringLiteral("Default"), Qt::CaseInsensitive) == 0;
@@ -108,97 +117,17 @@ void QtQuickControls2Plugin::registerTypes(const char *uri)
{
QQuickStylePrivate::init(baseUrl());
+ QQuickStylePlugin::registerTypes(uri);
+
const QString style = QQuickStyle::name();
if (!style.isEmpty())
QFileSelectorPrivate::addStatics(QStringList() << style.toLower());
- QQuickTheme *theme = createTheme(style.isEmpty() ? name() : style);
- if (isDefaultStyle(style))
- initializeTheme(theme);
-
- // load the style's plugins to get access to its resources and initialize the theme
- QList<QQuickStylePlugin *> stylePlugins = loadStylePlugins();
- for (QQuickStylePlugin *stylePlugin : stylePlugins)
- stylePlugin->initializeTheme(theme);
- qDeleteAll(stylePlugins);
-
// The minor version used to be the current Qt 5 minor. For compatibility it is the last
// Qt 5 release.
qmlRegisterModule(uri, 2, 15);
- // QtQuick.Controls 2.0 (originally introduced in Qt 5.7)
- qmlRegisterType(resolvedUrl(QStringLiteral("AbstractButton.qml")), uri, 2, 0, "AbstractButton");
- qmlRegisterType(resolvedUrl(QStringLiteral("ApplicationWindow.qml")), uri, 2, 0, "ApplicationWindow");
- qmlRegisterType(resolvedUrl(QStringLiteral("BusyIndicator.qml")), uri, 2, 0, "BusyIndicator");
- qmlRegisterType(resolvedUrl(QStringLiteral("Button.qml")), uri, 2, 0, "Button");
- qmlRegisterType(resolvedUrl(QStringLiteral("ButtonGroup.qml")), uri, 2, 0, "ButtonGroup");
- qmlRegisterType(resolvedUrl(QStringLiteral("CheckBox.qml")), uri, 2, 0, "CheckBox");
- qmlRegisterType(resolvedUrl(QStringLiteral("CheckDelegate.qml")), uri, 2, 0, "CheckDelegate");
- qmlRegisterType(resolvedUrl(QStringLiteral("ComboBox.qml")), uri, 2, 0, "ComboBox");
- qmlRegisterType(resolvedUrl(QStringLiteral("Container.qml")), uri, 2, 0, "Container");
- qmlRegisterType(resolvedUrl(QStringLiteral("Control.qml")), uri, 2, 0, "Control");
- qmlRegisterType(resolvedUrl(QStringLiteral("Dial.qml")), uri, 2, 0, "Dial");
- qmlRegisterType(resolvedUrl(QStringLiteral("Drawer.qml")), uri, 2, 0, "Drawer");
- qmlRegisterType(resolvedUrl(QStringLiteral("Frame.qml")), uri, 2, 0, "Frame");
- qmlRegisterType(resolvedUrl(QStringLiteral("GroupBox.qml")), uri, 2, 0, "GroupBox");
- qmlRegisterType(resolvedUrl(QStringLiteral("ItemDelegate.qml")), uri, 2, 0, "ItemDelegate");
- qmlRegisterType(resolvedUrl(QStringLiteral("Label.qml")), uri, 2, 0, "Label");
- qmlRegisterType(resolvedUrl(QStringLiteral("Menu.qml")), uri, 2, 0, "Menu");
- qmlRegisterType(resolvedUrl(QStringLiteral("MenuItem.qml")), uri, 2, 0, "MenuItem");
- qmlRegisterType(resolvedUrl(QStringLiteral("Page.qml")), uri, 2, 0, "Page");
- qmlRegisterType(resolvedUrl(QStringLiteral("PageIndicator.qml")), uri, 2, 0, "PageIndicator");
- qmlRegisterType(resolvedUrl(QStringLiteral("Pane.qml")), uri, 2, 0, "Pane");
- qmlRegisterType(resolvedUrl(QStringLiteral("Popup.qml")), uri, 2, 0, "Popup");
- qmlRegisterType(resolvedUrl(QStringLiteral("ProgressBar.qml")), uri, 2, 0, "ProgressBar");
- qmlRegisterType(resolvedUrl(QStringLiteral("RadioButton.qml")), uri, 2, 0, "RadioButton");
- qmlRegisterType(resolvedUrl(QStringLiteral("RadioDelegate.qml")), uri, 2, 0, "RadioDelegate");
- qmlRegisterType(resolvedUrl(QStringLiteral("RangeSlider.qml")), uri, 2, 0, "RangeSlider");
- qmlRegisterType(resolvedUrl(QStringLiteral("ScrollBar.qml")), uri, 2, 0, "ScrollBar");
- qmlRegisterType(resolvedUrl(QStringLiteral("ScrollIndicator.qml")), uri, 2, 0, "ScrollIndicator");
- qmlRegisterType(resolvedUrl(QStringLiteral("Slider.qml")), uri, 2, 0, "Slider");
- qmlRegisterType(resolvedUrl(QStringLiteral("SpinBox.qml")), uri, 2, 0, "SpinBox");
- qmlRegisterType(resolvedUrl(QStringLiteral("StackView.qml")), uri, 2, 0, "StackView");
- qmlRegisterType(resolvedUrl(QStringLiteral("SwipeDelegate.qml")), uri, 2, 0, "SwipeDelegate");
- qmlRegisterType(resolvedUrl(QStringLiteral("SwipeView.qml")), uri, 2, 0, "SwipeView");
- qmlRegisterType(resolvedUrl(QStringLiteral("Switch.qml")), uri, 2, 0, "Switch");
- qmlRegisterType(resolvedUrl(QStringLiteral("SwitchDelegate.qml")), uri, 2, 0, "SwitchDelegate");
- qmlRegisterType(resolvedUrl(QStringLiteral("TabBar.qml")), uri, 2, 0, "TabBar");
- qmlRegisterType(resolvedUrl(QStringLiteral("TabButton.qml")), uri, 2, 0, "TabButton");
- qmlRegisterType(resolvedUrl(QStringLiteral("TextArea.qml")), uri, 2, 0, "TextArea");
- qmlRegisterType(resolvedUrl(QStringLiteral("TextField.qml")), uri, 2, 0, "TextField");
- qmlRegisterType(resolvedUrl(QStringLiteral("ToolBar.qml")), uri, 2, 0, "ToolBar");
- qmlRegisterType(resolvedUrl(QStringLiteral("ToolButton.qml")), uri, 2, 0, "ToolButton");
- qmlRegisterType(resolvedUrl(QStringLiteral("ToolTip.qml")), uri, 2, 0, "ToolTip");
-#if QT_CONFIG(quick_listview) && QT_CONFIG(quick_pathview)
- qmlRegisterType(resolvedUrl(QStringLiteral("Tumbler.qml")), uri, 2, 0, "Tumbler");
-#endif
-
- // QtQuick.Controls 2.1 (new types in Qt 5.8)
- qmlRegisterType(resolvedUrl(QStringLiteral("Dialog.qml")), uri, 2, 1, "Dialog");
- qmlRegisterType(resolvedUrl(QStringLiteral("DialogButtonBox.qml")), uri, 2, 1, "DialogButtonBox");
- qmlRegisterType(resolvedUrl(QStringLiteral("MenuSeparator.qml")), uri, 2, 1, "MenuSeparator");
- qmlRegisterType(resolvedUrl(QStringLiteral("RoundButton.qml")), uri, 2, 1, "RoundButton");
- qmlRegisterType(resolvedUrl(QStringLiteral("ToolSeparator.qml")), uri, 2, 1, "ToolSeparator");
-
- // QtQuick.Controls 2.2 (new types in Qt 5.9)
- qmlRegisterType(resolvedUrl(QStringLiteral("DelayButton.qml")), uri, 2, 2, "DelayButton");
- qmlRegisterType(resolvedUrl(QStringLiteral("ScrollView.qml")), uri, 2, 2, "ScrollView");
-
- // QtQuick.Controls 2.3 (new types in Qt 5.10)
- qmlRegisterType(resolvedUrl(QStringLiteral("Action.qml")), uri, 2, 3, "Action");
- qmlRegisterType(resolvedUrl(QStringLiteral("ActionGroup.qml")), uri, 2, 3, "ActionGroup");
- qmlRegisterType(resolvedUrl(QStringLiteral("MenuBar.qml")), uri, 2, 3, "MenuBar");
- qmlRegisterType(resolvedUrl(QStringLiteral("MenuBarItem.qml")), uri, 2, 3, "MenuBarItem");
- qmlRegisterUncreatableType<QQuickOverlay>(uri, 2, 3, "Overlay", QStringLiteral("Overlay is only available as an attached property."));
-
- // QtQuick.Controls 2.13 (new types in Qt 5.13)
- qmlRegisterType(resolvedUrl(QStringLiteral("SplitView.qml")), uri, 2, 13, "SplitView");
- qmlRegisterUncreatableType<QQuickSplitHandleAttached>(uri, 2, 13, "SplitHandle",
- QStringLiteral("SplitHandle is only available as an attached property."));
-
- // QtQuick.Controls 2.15 (new types in Qt 5.15)
- qmlRegisterType(resolvedUrl(QStringLiteral("HorizontalHeaderView.qml")), uri, 2, 15, "HorizontalHeaderView");
- qmlRegisterType(resolvedUrl(QStringLiteral("VerticalHeaderView.qml")), uri, 2, 15, "VerticalHeaderView");
+ qmlRegisterTypesAndRevisions<QtQuickControls2Plugin>(uri, 2);
// The minor version used to be the current Qt 5 minor. For compatibility it is the last
// Qt 5 release.
@@ -256,6 +185,20 @@ void QtQuickControls2Plugin::initializeTheme(QQuickTheme *theme)
QQuickDefaultTheme::initialize(theme);
}
+void QtQuickControls2Plugin::init()
+{
+ const QString style = QQuickStyle::name();
+ QQuickTheme *theme = createTheme(style.isEmpty() ? name() : style);
+ if (isDefaultStyle(style))
+ initializeTheme(theme);
+
+ // load the style's plugins to get access to its resources and initialize the theme
+ QList<QQuickStylePlugin *> stylePlugins = loadStylePlugins();
+ for (QQuickStylePlugin *stylePlugin : stylePlugins)
+ stylePlugin->initializeTheme(theme);
+ qDeleteAll(stylePlugins);
+}
+
QList<QQuickStylePlugin *> QtQuickControls2Plugin::loadStylePlugins()
{
QList<QQuickStylePlugin *> stylePlugins;
diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp
index 9bbaad11..067d8dff 100644
--- a/src/quickcontrols2/qquickstyleplugin.cpp
+++ b/src/quickcontrols2/qquickstyleplugin.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
@@ -37,18 +37,14 @@
#include "qquickstyleplugin_p.h"
#include "qquickstyle.h"
#include "qquickstyle_p.h"
-#include "qquickstyleselector_p.h"
-QT_BEGIN_NAMESPACE
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlfile.h>
-class QQuickStylePluginPrivate
-{
-public:
- mutable QScopedPointer<QQuickStyleSelector> selector;
-};
+QT_BEGIN_NAMESPACE
QQuickStylePlugin::QQuickStylePlugin(QObject *parent)
- : QQmlExtensionPlugin(parent), d_ptr(new QQuickStylePluginPrivate)
+ : QQmlExtensionPlugin(parent)
{
}
@@ -66,34 +62,8 @@ void QQuickStylePlugin::initializeTheme(QQuickTheme *theme)
Q_UNUSED(theme);
}
-void QQuickStylePlugin::unregisterTypes()
+void QQuickStylePlugin::registerTypes(const char */*uri*/)
{
- Q_D(QQuickStylePlugin);
- // Destroy the selector so that it is recreated in resolvedUrl() and
- // any new style that has been set at runtime will be accounted for when selecting QML files.
- d->selector.reset();
-}
-
-QUrl QQuickStylePlugin::resolvedUrl(const QString &fileName) const
-{
- Q_D(const QQuickStylePlugin);
- if (!d->selector) {
- d->selector.reset(new QQuickStyleSelector);
- const QString style = QQuickStyle::name();
- if (!style.isEmpty())
- d->selector->addSelector(style);
-
- const QString fallback = QQuickStylePrivate::fallbackStyle();
- if (!fallback.isEmpty() && fallback != style)
- d->selector->addSelector(fallback);
-
- const QString theme = name();
- if (!theme.isEmpty() && theme != style)
- d->selector->addSelector(theme);
-
- d->selector->setPaths(QQuickStylePrivate::stylePaths(true));
- }
- return d->selector->select(fileName);
}
QT_END_NAMESPACE
diff --git a/src/quickcontrols2/qquickstyleplugin_p.h b/src/quickcontrols2/qquickstyleplugin_p.h
index 67103e12..a9700c15 100644
--- a/src/quickcontrols2/qquickstyleplugin_p.h
+++ b/src/quickcontrols2/qquickstyleplugin_p.h
@@ -54,7 +54,6 @@
QT_BEGIN_NAMESPACE
class QQuickTheme;
-class QQuickStylePluginPrivate;
class Q_QUICKCONTROLS2_PRIVATE_EXPORT QQuickStylePlugin : public QQmlExtensionPlugin
{
@@ -66,14 +65,11 @@ public:
virtual QString name() const;
virtual void initializeTheme(QQuickTheme *theme);
- virtual void unregisterTypes() override;
- QUrl resolvedUrl(const QString &fileName) const;
+ void registerTypes(const char *uri) override;
private:
Q_DISABLE_COPY(QQuickStylePlugin)
- Q_DECLARE_PRIVATE(QQuickStylePlugin)
- QScopedPointer<QQuickStylePluginPrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/quickcontrols2/qquickstyleselector.cpp b/src/quickcontrols2/qquickstyleselector.cpp
deleted file mode 100644
index 72e7af66..00000000
--- a/src/quickcontrols2/qquickstyleselector.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickstyleselector_p.h"
-#include "qquickstyleselector_p_p.h"
-
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qlocale.h>
-#include <QtCore/qloggingcategory.h>
-#include <QtCore/private/qfileselector_p.h>
-
-QT_BEGIN_NAMESPACE
-
-Q_LOGGING_CATEGORY(lcStyleSelectorSelect, "qt.quick.controls.styleSelector.select")
-Q_LOGGING_CATEGORY(lcStyleSelectorSetPaths, "qt.quick.controls.styleSelector.setPaths")
-Q_LOGGING_CATEGORY(lcStyleSelectorAddSelector, "qt.quick.controls.styleSelector.addSelector")
-
-static QString ensureSlash(const QString &path)
-{
- if (path.isEmpty() || path.endsWith(QLatin1Char('/')))
- return path;
- return path + QLatin1Char('/');
-}
-
-static QStringList prefixedPlatformSelectors(const QChar &prefix)
-{
- QStringList selectors = QFileSelectorPrivate::platformSelectors();
- for (int i = 0; i < selectors.count(); ++i)
- selectors[i].prepend(prefix);
- return selectors;
-}
-
-static QStringList allSelectors()
-{
- static const QStringList platformSelectors = prefixedPlatformSelectors(QLatin1Char('+'));
- QStringList selectors = platformSelectors;
- const QString locale = QLocale().name();
- if (!locale.isEmpty())
- selectors += QLatin1Char('+') + locale;
- return selectors;
-}
-
-QUrl QQuickStyleSelectorPrivate::select(const QString &filePath) const
-{
- QFileInfo fi(filePath);
- // If file doesn't exist, don't select
- if (!fi.exists())
- return QUrl();
-
- const QString selected = QFileSelectorPrivate::selectionHelper(ensureSlash(fi.canonicalPath()),
- fi.fileName(), allSelectors(), QChar());
-
- if (selected.startsWith(QLatin1Char(':')))
- return QUrl(QLatin1String("qrc") + selected);
-
- return QUrl::fromLocalFile(selected.isEmpty() ? filePath : selected);
-}
-
-QQuickStyleSelector::QQuickStyleSelector() : d_ptr(new QQuickStyleSelectorPrivate)
-{
-}
-
-QQuickStyleSelector::~QQuickStyleSelector()
-{
-}
-
-QStringList QQuickStyleSelector::selectors() const
-{
- Q_D(const QQuickStyleSelector);
- return d->selectors;
-}
-
-void QQuickStyleSelector::addSelector(const QString &selector)
-{
- Q_D(QQuickStyleSelector);
- if (d->selectors.contains(selector))
- return;
-
- d->selectors += selector;
-
- qCDebug(lcStyleSelectorSetPaths).nospace() << "added selector " << selector
- << "; full list is now: " << d->selectors;
-}
-
-QStringList QQuickStyleSelector::paths() const
-{
- Q_D(const QQuickStyleSelector);
- return d->paths;
-}
-
-void QQuickStyleSelector::setPaths(const QStringList &paths)
-{
- Q_D(QQuickStyleSelector);
- qCDebug(lcStyleSelectorSetPaths) << "setting paths to" << paths;
- d->paths = paths;
-}
-
-QUrl QQuickStyleSelector::select(const QString &fileName) const
-{
- Q_D(const QQuickStyleSelector);
- // The lookup order is
- // 1) requested style (e.g. "MyStyle", included in d->selectors)
- // 2) fallback style (e.g. "Material", included in d->selectors)
- // 3) default style (empty selector, not in d->selectors)
- qCDebug(lcStyleSelectorSelect) << "selecting" << fileName << "from" << d->paths << "with selectors" << d->selectors;
-
- int to = d->selectors.count() - 1;
- if (d->selectors.isEmpty() || !d->selectors.first().isEmpty())
- ++to; // lookup #3 unless #1 is also empty (redundant)
-
- // NOTE: last iteration intentionally out of bounds => empty selector
- for (int i = 0; i <= to; ++i) {
- const QString selector = d->selectors.value(i);
- for (const QString &path : d->paths) {
- const QUrl selectedUrl = d->select(ensureSlash(path) + selector + QLatin1Char('/') + fileName);
- if (selectedUrl.isValid()) {
- qCDebug(lcStyleSelectorSelect) << "==>" << selectedUrl << "from" << path << "with selector" << selector;
- return selectedUrl;
- }
- }
- }
-
- return fileName;
-}
-
-QT_END_NAMESPACE
diff --git a/src/quickcontrols2/qquickstyleselector_p.h b/src/quickcontrols2/qquickstyleselector_p.h
deleted file mode 100644
index c4c0f540..00000000
--- a/src/quickcontrols2/qquickstyleselector_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKSTYLESELECTOR_P_H
-#define QQUICKSTYLESELECTOR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qurl.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qscopedpointer.h>
-#include <QtQuickControls2/private/qtquickcontrols2global_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickStyleSelectorPrivate;
-
-class Q_QUICKCONTROLS2_PRIVATE_EXPORT QQuickStyleSelector
-{
-public:
- QQuickStyleSelector();
- ~QQuickStyleSelector();
-
- QStringList selectors() const;
- void addSelector(const QString &selector);
-
- QStringList paths() const;
- void setPaths(const QStringList &paths);
-
- QUrl select(const QString &fileName) const;
-
-private:
- Q_DISABLE_COPY(QQuickStyleSelector)
- Q_DECLARE_PRIVATE(QQuickStyleSelector)
- QScopedPointer<QQuickStyleSelectorPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKSTYLESELECTOR_P_H
diff --git a/src/quickcontrols2/qquickstyleselector_p_p.h b/src/quickcontrols2/qquickstyleselector_p_p.h
deleted file mode 100644
index e69e7db2..00000000
--- a/src/quickcontrols2/qquickstyleselector_p_p.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/***************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKSTYLESELECTOR_P_P_H
-#define QQUICKSTYLESELECTOR_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtQuickControls2/private/qquickstyleselector_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickStyleSelectorPrivate
-{
-public:
- QUrl select(const QString &filePath) const;
-
- QStringList paths;
- QStringList selectors;
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKSTYLESELECTOR_P_P_H
diff --git a/src/quickcontrols2/quickcontrols2.pri b/src/quickcontrols2/quickcontrols2.pri
index 781658ef..2c28038f 100644
--- a/src/quickcontrols2/quickcontrols2.pri
+++ b/src/quickcontrols2/quickcontrols2.pri
@@ -15,9 +15,7 @@ HEADERS += \
$$PWD/qquickplaceholdertext_p.h \
$$PWD/qquickstyle.h \
$$PWD/qquickstyle_p.h \
- $$PWD/qquickstyleplugin_p.h \
- $$PWD/qquickstyleselector_p.h \
- $$PWD/qquickstyleselector_p_p.h
+ $$PWD/qquickstyleplugin_p.h
SOURCES += \
$$PWD/qquickanimatednode.cpp \
@@ -33,8 +31,7 @@ SOURCES += \
$$PWD/qquickpaddedrectangle.cpp \
$$PWD/qquickplaceholdertext.cpp \
$$PWD/qquickstyle.cpp \
- $$PWD/qquickstyleplugin.cpp \
- $$PWD/qquickstyleselector.cpp
+ $$PWD/qquickstyleplugin.cpp
qtConfig(quick-listview):qtConfig(quick-pathview) {
HEADERS += \
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 03b6369d..e41723ea 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -24,7 +24,6 @@ SUBDIRS += \
qquickninepatchimage \
qquickpopup \
qquickstyle \
- qquickstyleselector \
qquickuniversalstyle \
qquickuniversalstyleconf \
revisions \
diff --git a/tests/auto/qquickstyleselector/CMakeLists.txt b/tests/auto/qquickstyleselector/CMakeLists.txt
deleted file mode 100644
index 3a489ccf..00000000
--- a/tests/auto/qquickstyleselector/CMakeLists.txt
+++ /dev/null
@@ -1,61 +0,0 @@
-# Generated from qquickstyleselector.pro.
-
-#####################################################################
-## tst_qquickstyleselector Test:
-#####################################################################
-
-# Collect test data
-file(GLOB_RECURSE test_data_glob
- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
- data/*)
-list(APPEND test_data ${test_data_glob})
-
-qt_add_test(tst_qquickstyleselector
- SOURCES
- ../shared/qtest_quickcontrols.h
- ../shared/util.cpp ../shared/util.h
- ../shared/visualtestutil.cpp ../shared/visualtestutil.h
- tst_qquickstyleselector.cpp
- DEFINES
- QQC2_IMPORT_PATH=\\\"${CMAKE_CURRENT_SOURCE_DIR}/../../../src/imports\\\"
- PUBLIC_LIBRARIES
- Qt::CorePrivate
- Qt::Gui
- Qt::GuiPrivate
- Qt::QmlPrivate
- Qt::QuickControls2
- Qt::QuickControls2Private
- Qt::QuickPrivate
- Qt::QuickTemplates2Private
- Qt::TestPrivate
- TESTDATA ${test_data}
-)
-
-# Resources:
-set(qmake_resourcestyle_resource_files
- "ResourceStyle/Button.qml"
-)
-
-qt_add_resource(tst_qquickstyleselector "qmake_resourcestyle"
- PREFIX
- "/"
- FILES
- ${qmake_resourcestyle_resource_files}
-)
-
-
-#### Keys ignored in scope 1:.:.:qquickstyleselector.pro:<TRUE>:
-# OTHER_FILES = "data/*.qml"
-
-## Scopes:
-#####################################################################
-
-qt_extend_target(tst_qquickstyleselector CONDITION ANDROID OR IOS
- DEFINES
- QT_QMLTEST_DATADIR=\\\":/data\\\"
-)
-
-qt_extend_target(tst_qquickstyleselector CONDITION NOT ANDROID AND NOT IOS
- DEFINES
- QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\"
-)
diff --git a/tests/auto/qquickstyleselector/ResourceStyle/Button.qml b/tests/auto/qquickstyleselector/ResourceStyle/Button.qml
deleted file mode 100644
index eaeeadcd..00000000
--- a/tests/auto/qquickstyleselector/ResourceStyle/Button.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/Button.qml b/tests/auto/qquickstyleselector/data/Button.qml
deleted file mode 100644
index eaeeadcd..00000000
--- a/tests/auto/qquickstyleselector/data/Button.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/Control.qml b/tests/auto/qquickstyleselector/data/Control.qml
deleted file mode 100644
index 6820b57d..00000000
--- a/tests/auto/qquickstyleselector/data/Control.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Control { }
diff --git a/tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml b/tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml
deleted file mode 100644
index eaeeadcd..00000000
--- a/tests/auto/qquickstyleselector/data/FallbackStyle/Button.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml b/tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml
deleted file mode 100644
index 23699c1c..00000000
--- a/tests/auto/qquickstyleselector/data/FallbackStyle/Label.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Label { }
diff --git a/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml b/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml
deleted file mode 100644
index eaeeadcd..00000000
--- a/tests/auto/qquickstyleselector/data/FileSystemStyle/Button.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/Label.qml b/tests/auto/qquickstyleselector/data/Label.qml
deleted file mode 100644
index 23699c1c..00000000
--- a/tests/auto/qquickstyleselector/data/Label.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Label { }
diff --git a/tests/auto/qquickstyleselector/data/PlatformStyle/+linux/Button.qml b/tests/auto/qquickstyleselector/data/PlatformStyle/+linux/Button.qml
deleted file mode 100644
index eaeeadcd..00000000
--- a/tests/auto/qquickstyleselector/data/PlatformStyle/+linux/Button.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/PlatformStyle/+macos/Button.qml b/tests/auto/qquickstyleselector/data/PlatformStyle/+macos/Button.qml
deleted file mode 100644
index eaeeadcd..00000000
--- a/tests/auto/qquickstyleselector/data/PlatformStyle/+macos/Button.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/PlatformStyle/+windows/Button.qml b/tests/auto/qquickstyleselector/data/PlatformStyle/+windows/Button.qml
deleted file mode 100644
index eaeeadcd..00000000
--- a/tests/auto/qquickstyleselector/data/PlatformStyle/+windows/Button.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Button { }
diff --git a/tests/auto/qquickstyleselector/data/PlatformStyle/Button.qml b/tests/auto/qquickstyleselector/data/PlatformStyle/Button.qml
deleted file mode 100644
index eaeeadcd..00000000
--- a/tests/auto/qquickstyleselector/data/PlatformStyle/Button.qml
+++ /dev/null
@@ -1,2 +0,0 @@
-import QtQuick.Templates 2.12 as T
-T.Button { }
diff --git a/tests/auto/qquickstyleselector/qquickstyleselector.pro b/tests/auto/qquickstyleselector/qquickstyleselector.pro
deleted file mode 100644
index 6569b46d..00000000
--- a/tests/auto/qquickstyleselector/qquickstyleselector.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickstyleselector
-SOURCES += tst_qquickstyleselector.cpp
-
-macos:CONFIG -= app_bundle
-
-QT += core-private gui-private qml-private quick-private quickcontrols2-private testlib
-
-include (../shared/util.pri)
-
-resourcestyle.prefix = /
-resourcestyle.files += $$PWD/ResourceStyle/Button.qml
-RESOURCES += resourcestyle
-
-TESTDATA = data/*
-
-OTHER_FILES += \
- data/*.qml
-
diff --git a/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp b/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp
deleted file mode 100644
index ce2e2e99..00000000
--- a/tests/auto/qquickstyleselector/tst_qquickstyleselector.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/qtest.h>
-#include <QtQuickControls2/qquickstyle.h>
-#include <QtQuickControls2/private/qquickstyle_p.h>
-#include <QtQuickControls2/private/qquickstyleselector_p.h>
-#include "../shared/util.h"
-
-class tst_QQuickStyleSelector : public QQmlDataTest
-{
- Q_OBJECT
-
-private slots:
- void initTestCase();
-
- void select_data();
- void select();
-
- void platformSelectors();
-};
-
-void tst_QQuickStyleSelector::initTestCase()
-{
- QQmlDataTest::initTestCase();
- QQuickStylePrivate::init(dataDirectoryUrl());
-}
-
-void tst_QQuickStyleSelector::select_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("style");
- QTest::addColumn<QString>("path");
- QTest::addColumn<QString>("fallback");
- QTest::addColumn<QString>("expected");
-
- // Control.qml exists only in the default style
- QTest::newRow("control") << "Control.qml" << "" << "data" << "" << testFileUrl("Control.qml").toString();
- QTest::newRow("/control") << "Control.qml" << "" << dataDirectory() << "" << testFileUrl("Control.qml").toString();
- QTest::newRow("fs/control") << "Control.qml" << "FileSystemStyle" << "data" << "" << testFileUrl("Control.qml").toString();
- QTest::newRow("/fs/control") << "Control.qml" << "FileSystemStyle" << dataDirectory() << "" << testFileUrl("Control.qml").toString();
- QTest::newRow(":/control") << "Control.qml" << "ResourceStyle" << ":/" << "" << testFileUrl("Control.qml").toString();
- QTest::newRow("qrc:/control") << "Control.qml" << "ResourceStyle" << "qrc:/" << "" << testFileUrl("Control.qml").toString();
- QTest::newRow("nosuch/control") << "Control.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Control.qml").toString();
- QTest::newRow("/nosuch/control") << "Control.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Control.qml").toString();
-
- QTest::newRow("control->base") << "Control.qml" << "" << "data" << "FallbackStyle" << testFileUrl("Control.qml").toString();
- QTest::newRow("/control->base") << "Control.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Control.qml").toString();
- QTest::newRow("fs/control->base") << "Control.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("Control.qml").toString();
- QTest::newRow("/fs/control->base") << "Control.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("Control.qml").toString();
- QTest::newRow(":/control->base") << "Control.qml" << "ResourceStyle" << ":/" << "FallbackStyle" << testFileUrl("Control.qml").toString();
- QTest::newRow("qrc:/control->base") << "Control.qml" << "ResourceStyle" << "qrc:/" << "FallbackStyle" << testFileUrl("Control.qml").toString();
- QTest::newRow("nosuch/control->base") << "Control.qml" << "NoSuchStyle" << "data" << "FallbackStyle" << testFileUrl("Control.qml").toString();
- QTest::newRow("/nosuch/control->base") << "Control.qml" << "NoSuchStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("Control.qml").toString();
-
- // Label.qml exists in the default and fallback styles
- QTest::newRow("label") << "Label.qml" << "" << "data" << "" << testFileUrl("Label.qml").toString();
- QTest::newRow("/label") << "Label.qml" << "" << dataDirectory() << "" << testFileUrl("Label.qml").toString();
- QTest::newRow("fs/label") << "Label.qml" << "FileSystemStyle" << "data" << "" << testFileUrl("Label.qml").toString();
- QTest::newRow("/fs/label") << "Label.qml" << "FileSystemStyle" << dataDirectory() << "" << testFileUrl("Label.qml").toString();
- QTest::newRow(":/label") << "Label.qml" << "ResourceStyle" << ":/" << "" << testFileUrl("Label.qml").toString();
- QTest::newRow("qrc:/label") << "Label.qml" << "ResourceStyle" << "qrc:/" << "" << testFileUrl("Label.qml").toString();
- QTest::newRow("nosuch/label") << "Label.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Label.qml").toString();
- QTest::newRow("/nosuch/label") << "Label.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Label.qml").toString();
-
- QTest::newRow("label->base") << "Label.qml" << "" << "data" << "FallbackStyle" << testFileUrl("Label.qml").toString();
- QTest::newRow("/label->base") << "Label.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Label.qml").toString();
- QTest::newRow("fs/label->base") << "Label.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
- QTest::newRow("/fs/label->base") << "Label.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
- QTest::newRow(":/label->base") << "Label.qml" << "ResourceStyle" << ":/" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
- QTest::newRow("qrc:/label->base") << "Label.qml" << "ResourceStyle" << "qrc:/" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
- QTest::newRow("nosuch/label->base") << "Label.qml" << "NoSuchStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
- QTest::newRow("/nosuch/label->base") << "Label.qml" << "NoSuchStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Label.qml").toString();
-
- // Button.qml exists in all styles including the fs and qrc styles
- QTest::newRow("button") << "Button.qml" << "" << "data" << "" << testFileUrl("Button.qml").toString();
- QTest::newRow("/button") << "Button.qml" << "" << dataDirectory() << "" << testFileUrl("Button.qml").toString();
- QTest::newRow("fs/button") << "Button.qml" << "FileSystemStyle" << "data" << "" << testFileUrl("FileSystemStyle/Button.qml").toString();
- QTest::newRow("/fs/button") << "Button.qml" << "FileSystemStyle" << dataDirectory() << "" << testFileUrl("FileSystemStyle/Button.qml").toString();
- QTest::newRow(":/button") << "Button.qml" << "ResourceStyle" << ":/" << "" << "qrc:/ResourceStyle/Button.qml";
- QTest::newRow("qrc:/button") << "Button.qml" << "ResourceStyle" << "qrc:/" << "" << "qrc:/ResourceStyle/Button.qml";
- QTest::newRow("nosuch/button") << "Button.qml" << "NoSuchStyle" << "data" << "" << testFileUrl("Button.qml").toString();
- QTest::newRow("/nosuch/button") << "Button.qml" << "NoSuchStyle" << dataDirectory() << "" << testFileUrl("Button.qml").toString();
-
- QTest::newRow("button->base") << "Button.qml" << "" << "data" << "FallbackStyle" << testFileUrl("Button.qml").toString();
- QTest::newRow("/button->base") << "Button.qml" << "" << dataDirectory() << "FallbackStyle" << testFileUrl("Button.qml").toString();
- QTest::newRow("fs/button->base") << "Button.qml" << "FileSystemStyle" << "data" << "FallbackStyle" << testFileUrl("FileSystemStyle/Button.qml").toString();
- QTest::newRow("/fs/button->base") << "Button.qml" << "FileSystemStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FileSystemStyle/Button.qml").toString();
- QTest::newRow(":/button->base") << "Button.qml" << "ResourceStyle" << ":/" << "FallbackStyle" << "qrc:/ResourceStyle/Button.qml";
- QTest::newRow("qrc:/button->base") << "Button.qml" << "ResourceStyle" << "qrc:/" << "FallbackStyle" << "qrc:/ResourceStyle/Button.qml";
- QTest::newRow("nosuch/button->base") << "Button.qml" << "NoSuchStyle" << "data" << "FallbackStyle" << testFileUrl("FallbackStyle/Button.qml").toString();
- QTest::newRow("/nosuch/button->base") << "Button.qml" << "NoSuchStyle" << dataDirectory() << "FallbackStyle" << testFileUrl("FallbackStyle/Button.qml").toString();
-}
-
-void tst_QQuickStyleSelector::select()
-{
- QFETCH(QString, file);
- QFETCH(QString, style);
- QFETCH(QString, path);
- QFETCH(QString, fallback);
- QFETCH(QString, expected);
-
- QQuickStyle::setStyle(QDir(path).filePath(style));
- QQuickStyle::setFallbackStyle(fallback);
-
- QQuickStyleSelector selector;
- selector.addSelector(style);
- selector.addSelector(fallback);
- selector.setPaths(QStringList() << dataDirectory() << ":/");
- QCOMPARE(selector.select(file), expected);
-}
-
-void tst_QQuickStyleSelector::platformSelectors()
-{
- QQuickStyle::setStyle(QDir(dataDirectory()).filePath("PlatformStyle"));
-
- QQuickStyleSelector selector;
- selector.addSelector("PlatformStyle");
- selector.setPaths(QStringList() << dataDirectory());
-
-#if defined(Q_OS_LINUX)
- QCOMPARE(selector.select("Button.qml"), testFileUrl("PlatformStyle/+linux/Button.qml").toString());
-#elif defined(Q_OS_MACOS)
- QCOMPARE(selector.select("Button.qml"), testFileUrl("PlatformStyle/+macos/Button.qml").toString());
-#elif defined(Q_OS_WIN)
- QCOMPARE(selector.select("Button.qml"), testFileUrl("PlatformStyle/+windows/Button.qml").toString());
-#else
- QCOMPARE(selector.select("Button.qml"), testFileUrl("PlatformStyle/Button.qml").toString());
-#endif
-}
-
-QTEST_MAIN(tst_QQuickStyleSelector)
-
-#include "tst_qquickstyleselector.moc"