aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls/qtquickcontrols2plugin.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-03-12 16:51:32 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-03-13 10:37:59 +0000
commit0cd3f970fff9643129a046a2bab1d79ce2f97c28 (patch)
tree54f9453c55068ba864cb3c212f6476dc7ed71310 /src/imports/controls/qtquickcontrols2plugin.cpp
parent57aa9580f07307c5e277e52362943e7efd1f9ac9 (diff)
Refactor QQuickStyleSelector
Instead of trying to determine a single base URL based on the import URI of the plugin, and whether built in static mode, provide a list of paths where to lookup styles, in priority order: - requested style path (-style /path/to/style) - QT_QUICK_CONTROLS_STYLE_PATH environment variable - QT_INSTALL_QML/QtQuick/Controls.2/ - qrc://qt-project.org/imports/QtQuick/Controls.2/ Furthermore, provide the requested style name and the fallback style name as a simple list of selectors. The lookup order is: 1) requested style 2) fallback style 3) default style As a result, QQuickStyleSelector implementation is a lot simpler, completely independent of QQuickStyle, and the style lookup works regardless of whether the files are in QRC or on the file system. This allows us to utilize QRC and the Qt Quick Compiler in the future. Note: two data rows in tst_QQuickStyleSelector::select_data() had to be fixed. Not sure how the expected values ended up like that, but as the comments say, "Label.qml exists in the default and fallback styles" and "Button.qml exists in all styles", so it makes no sense to expect that Label.qml or Button.qml is selected from the FallbackStyle when a valid "data" folder is specified. Change-Id: I18dea9fddf8f079e0140b51b567814da0df2802c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports/controls/qtquickcontrols2plugin.cpp')
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index c495b6b2..d0018901 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -98,12 +98,17 @@ QtQuickControls2Plugin::~QtQuickControls2Plugin()
void QtQuickControls2Plugin::registerTypes(const char *uri)
{
QQuickStylePrivate::init(typeUrl());
+
const QString style = QQuickStyle::name();
+ const QString fallback = QQuickStylePrivate::fallbackStyle();
if (!style.isEmpty())
QFileSelectorPrivate::addStatics(QStringList() << style.toLower());
QQuickStyleSelector selector;
- selector.setBaseUrl(typeUrl());
+ selector.addSelector(style);
+ if (!fallback.isEmpty())
+ selector.addSelector(fallback);
+ selector.setPaths(QQuickStylePrivate::stylePaths(true));
qmlRegisterModule(uri, 2, QT_VERSION_MINOR - 7); // Qt 5.7->2.0, 5.8->2.1, 5.9->2.2...