diff options
-rw-r--r-- | src/core/kconfiggroup.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp index 39d2441a..f6eb2f52 100644 --- a/src/core/kconfiggroup.cpp +++ b/src/core/kconfiggroup.cpp @@ -416,24 +416,13 @@ static QString translatePath(QString path) // krazy:exclude=passbyvalue // only "our" $HOME should be interpreted path.replace(QLatin1Char('$'), QLatin1String("$$")); - bool startsWithFile = path.startsWith(QLatin1String("file:"), Qt::CaseInsensitive); + const bool startsWithFile = path.startsWith(QLatin1String("file:"), Qt::CaseInsensitive); + path = startsWithFile ? QUrl(path).toLocalFile() : path; - // return original path, if it refers to another type of URL (e.g. http:/), or - // if the path is already relative to another directory - if ((!startsWithFile && QFileInfo(path).isRelative()) || - (startsWithFile && QFileInfo(path.mid(5)).isRelative())) { + if (QDir::isRelativePath(path)) { return path; } - if (startsWithFile) { - path.remove(0, 5); // strip leading "file:/" off the string - } - - // keep only one single '/' at the beginning - needed for cleanHomeDirPath() - while (path[0] == QLatin1Char('/') && path[1] == QLatin1Char('/')) { - path.remove(0, 1); - } - // we can not use KGlobal::dirs()->relativeLocation("home", path) here, // since it would not recognize paths without a trailing '/'. // All of the 3 following functions to return the user's home directory @@ -448,7 +437,7 @@ static QString translatePath(QString path) // krazy:exclude=passbyvalue } if (startsWithFile) { - path.prepend(QStringLiteral("file://")); + path = QUrl::fromLocalFile(path).toString(); } return path; |