aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols2/qquickstyle.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-08-20 14:38:47 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-08-25 11:03:56 +0000
commit54480f3fb6312205170cff3a16d84d53a2da143f (patch)
treedff0329fa408e33303a97c2eda85f1928dacf29a /src/quickcontrols2/qquickstyle.cpp
parentde488d3ccdb98c2820176192a78c00f08ccfd83c (diff)
Init QQuickStyle's base URL to avoid creating temp QQmlEngine
Initialize the base URL from QtQuickControls2Plugin::registerTypes() to avoid creating an unnecessary temporary instance of QQmlEngine. It was used to list all known import paths, which were scanned for the requested style folder. Now that we pass the base URL, the built-in styles (a name without path to the style) can be looked up straight from the base path. Change-Id: I0d68d4c5bb90a4ab89660b5ce97f6433aeefc1ff Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quickcontrols2/qquickstyle.cpp')
-rw-r--r--src/quickcontrols2/qquickstyle.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp
index f432eded..bee837e9 100644
--- a/src/quickcontrols2/qquickstyle.cpp
+++ b/src/quickcontrols2/qquickstyle.cpp
@@ -35,6 +35,7 @@
****************************************************************************/
#include "qquickstyle.h"
+#include "qquickstyle_p.h"
#include "qquickstyleattached_p.h"
#include <QtCore/qdir.h>
@@ -88,8 +89,6 @@ struct QQuickStyleSpec
QString name()
{
- if (!resolved)
- resolve();
return style.mid(style.lastIndexOf(QLatin1Char('/')) + 1);
}
@@ -110,7 +109,7 @@ struct QQuickStyleSpec
resolve();
}
- void resolve()
+ void resolve(const QUrl &baseUrl = QUrl())
{
if (style.isEmpty())
style = QGuiApplicationPrivate::styleOverride;
@@ -122,6 +121,13 @@ struct QQuickStyleSpec
style = settings->value(QStringLiteral("Style")).toString();
}
+ if (baseUrl.isValid()) {
+ if (style.isEmpty())
+ style = baseUrl.toString(QUrl::StripTrailingSlash) + QLatin1Char('/');
+ else if (!style.contains(QLatin1Char('/')))
+ style = baseUrl.toString(QUrl::StripTrailingSlash) + QLatin1Char('/') + style;
+ }
+
if (QGuiApplication::instance()) {
if (!style.contains(QLatin1Char('/'))) {
const QString targetPath = QStringLiteral("QtQuick/Controls.2");
@@ -158,6 +164,11 @@ struct QQuickStyleSpec
Q_GLOBAL_STATIC(QQuickStyleSpec, styleSpec)
+void QQuickStylePrivate::init(const QUrl &baseUrl)
+{
+ styleSpec()->resolve(baseUrl);
+}
+
/*!
Returns the name of the application style.