Fix handling special chars like # in openLocalFileOrDir()

This commit is contained in:
Martchus 2016-12-27 20:22:20 +01:00
parent 60403202df
commit 783c00b78c
1 changed files with 6 additions and 2 deletions

View File

@ -16,9 +16,13 @@ bool openLocalFileOrDir(const QString &path)
// -> replace backslashes with slashes to support Windows paths
QString tmp(path);
tmp.replace(QChar('\\'), QChar('/'));
return QDesktopServices::openUrl(QUrl(QStringLiteral("file:///") + path, QUrl::TolerantMode));
QUrl url(QStringLiteral("file:///"));
url.setPath(tmp, QUrl::DecodedMode);
return QDesktopServices::openUrl(url);
#else
return QDesktopServices::openUrl(QUrl(QStringLiteral("file://") + path, QUrl::TolerantMode));
QUrl url(QStringLiteral("file://"));
url.setPath(path, QUrl::DecodedMode);
return QDesktopServices::openUrl(url);
#endif
}