diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-07-17 03:00:30 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-07-17 09:45:48 +0000 |
commit | d96bd6069c6d24c12f0a3d96466e50b4d1a09ac4 (patch) | |
tree | b1250acd86c482fc92cd90d1733f0a436d1c2a78 /src/quickcontrols2 | |
parent | 1567e4581e1f82dae011d6d3b2e4196efc93b0f4 (diff) | |
parent | 449c9c2474da0461c14e7d6ea12ff4e35c3c7aae (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
src/quickcontrols2/qquickstyle.cpp
src/quicktemplates2/qquickscrollview.cpp
tests/auto/qquickstyle/tst_qquickstyle.cpp
Change-Id: I9afddf07a956f43cf0445e91b8d1a02f167b6bd5
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r-- | src/quickcontrols2/qquickstyle.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index 9f101273..b4901db3 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -271,6 +271,54 @@ struct QQuickStyleSpec Q_GLOBAL_STATIC(QQuickStyleSpec, styleSpec) +static QStringList parseStylePathsWithColon(const QString &var) +{ + QStringList paths; + const QChar colon = QLatin1Char(':'); + int currentIndex = 0; + + do { + int nextColonIndex = -1; + QString path; + + if (var.at(currentIndex) == colon) { + // This is either a list separator, or a qrc path. + if (var.at(currentIndex + 1) == colon) { + // It's a double colon (list separator followed by qrc path); + // find the end of the path. + nextColonIndex = var.indexOf(colon, currentIndex + 2); + path = var.mid(currentIndex + 1, + nextColonIndex == -1 ? -1 : nextColonIndex - currentIndex - 1); + } else { + // It's a single colon. + nextColonIndex = var.indexOf(colon, currentIndex + 1); + if (currentIndex == 0) { + // If we're at the start of the string, then it's a qrc path. + path = var.mid(currentIndex, + nextColonIndex == -1 ? -1 : nextColonIndex - currentIndex); + } else { + // Otherwise, it's a separator. + path = var.mid(currentIndex + 1, + nextColonIndex == -1 ? -1 : nextColonIndex - currentIndex - 1); + } + } + } else { + // It's a file path. + nextColonIndex = var.indexOf(colon, currentIndex); + path = var.mid(currentIndex, + nextColonIndex == -1 ? -1 : nextColonIndex - currentIndex); + } + + paths += path; + currentIndex = nextColonIndex; + + // Keep going until we can't find any more colons, + // or we're at the last character. + } while (currentIndex != -1 && currentIndex < var.size() - 1); + + return paths; +} + QStringList QQuickStylePrivate::stylePaths(bool resolve) { // user-requested style path @@ -283,6 +331,21 @@ QStringList QQuickStylePrivate::stylePaths(bool resolve) paths += path; } + if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE_PATH"))) { + const QString value = QString::fromLocal8Bit(qgetenv("QT_QUICK_CONTROLS_STYLE_PATH")); + const QChar listSeparator = QDir::listSeparator(); + if (listSeparator == QLatin1Char(':')) { + // Split manually to avoid breaking paths on systems where : is the list separator, + // since it's also used for qrc paths. + paths += parseStylePathsWithColon(value); + } else { + // Fast/simpler path for systems where something other than : is used as + // the list separator (such as ';'). + const QStringList customPaths = value.split(listSeparator, QString::SkipEmptyParts); + paths += customPaths; + } + } + // system/custom style paths paths += styleSpec()->customStylePaths; paths += envPathList("QT_QUICK_CONTROLS_STYLE_PATH"); |