aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols2/qquickstyle.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-11-11 14:42:33 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-11-16 16:43:21 +0000
commit94d98bdb6326e784b8397044d50226daaefd6cce (patch)
tree97f553a9cd29852a95c04251021aa42f079bf6f1 /src/quickcontrols2/qquickstyle.cpp
parent396e680fd5f066177f7d1d77966a4d8e2e4df20f (diff)
Add support for a QT_QUICK_CONTROLS_STYLE_PATH environment variable
[ChangeLog][Controls][Styles] Added support for a QT_QUICK_CONTROLS_STYLE_PATH environment variable, which can be used to specify lookup paths for Qt Quick Controls 2 styles. This allows device manufacturers and Linux distributions to specify a system-wide style installation folder that may be located outside the Qt installation tree. Change-Id: Ic004d693bf6206971da6319d0cc13061b8fd1566 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quickcontrols2/qquickstyle.cpp')
-rw-r--r--src/quickcontrols2/qquickstyle.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp
index c8a3f19a..4247b204 100644
--- a/src/quickcontrols2/qquickstyle.cpp
+++ b/src/quickcontrols2/qquickstyle.cpp
@@ -182,6 +182,7 @@ struct QQuickStyleSpec
for (const QString &path : stylePaths) {
QString stylePath = findStyle(path, style);
if (!stylePath.isEmpty()) {
+ custom = !stylePath.startsWith(baseUrl.toLocalFile());
style = stylePath;
resolved = true;
break;
@@ -212,15 +213,22 @@ Q_GLOBAL_STATIC(QQuickStyleSpec, styleSpec)
QStringList QQuickStylePrivate::stylePaths()
{
+ // system/custom style paths
+ QStringList paths;
+ if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE_PATH"))) {
+ const QByteArray value = qgetenv("QT_QUICK_CONTROLS_STYLE_PATH");
+ paths += QString::fromLatin1(value).split(QDir::listSeparator(), QString::SkipEmptyParts);
+ }
+
+ // built-in import paths
const QString targetPath = QStringLiteral("QtQuick/Controls.2");
const QStringList importPaths = QQmlEngine().importPathList();
-
- QStringList paths;
for (const QString &importPath : importPaths) {
QDir dir(importPath);
if (dir.cd(targetPath))
paths += dir.absolutePath();
}
+
return paths;
}