diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-04-23 19:34:15 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-04-25 07:19:42 +0000 |
commit | f2ede1a01237c0ff0285716359a8b57a6676a94d (patch) | |
tree | df970a6cae126a6698706370232e878c595c1f14 /src/quickcontrols2 | |
parent | 99fa43b3708d6615e17d0cc5561aca78a9c72d1a (diff) |
QQuickStyleSelector: fix relative path handling
This makes it possible to pass a relative path to the style:
./myapp -style relative/path/to/my/style
To make the tests pass, includes a fix to avoid double slashes in
selected URLs.
Change-Id: I1b366eb7793523dd0f1058236661cedaa1216f3d
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r-- | src/quickcontrols2/qquickstyleselector.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/quickcontrols2/qquickstyleselector.cpp b/src/quickcontrols2/qquickstyleselector.cpp index cd89ba95..93249192 100644 --- a/src/quickcontrols2/qquickstyleselector.cpp +++ b/src/quickcontrols2/qquickstyleselector.cpp @@ -144,11 +144,15 @@ QString QQuickStyleSelector::select(const QString &fileName) const const QString selectedPath = selectionHelper(stylePath, fileName, allSelectors(false)); if (selectedPath.startsWith(QLatin1Char(':'))) return QLatin1String("qrc") + selectedPath; - return QUrl::fromLocalFile(selectedPath).toString(); + return QUrl::fromLocalFile(QFileInfo(selectedPath).absoluteFilePath()).toString(); } } - QUrl url(d->baseUrl.toString() + QLatin1Char('/') + fileName); + QString base = d->baseUrl.toString(); + if (!base.isEmpty() && !base.endsWith(QLatin1Char('/'))) + base += QLatin1Char('/'); + + QUrl url(base + fileName); if (isLocalScheme(url.scheme())) { QString equivalentPath = QLatin1Char(':') + url.path(); QString selectedPath = d->select(equivalentPath); |