Commit c0008f9c authored by Harald Sitter's avatar Harald Sitter 🦄

use toLocalFile instead of path of the QUrl to fix Win32 compat

path() would be /foo irregardless of platform, on Windows that's /C:/ which
is not correct as the local representation is C:/. toLocalFile handles this
for us.

I've also changed the var name to be more representitive of what it
contains and is used for i.e. checking the localPath. should remote URL
validation be introduced at a later point it would then be obvious that one
should not be using that particular variable ;)
parent a137784a
......@@ -364,7 +364,7 @@ bool MainWindow::openUrl(const QUrl &u)
#define KMSG(s) KMessageBox::information(widget(), s)
QUrl uri = u.adjusted(QUrl::NormalizePathSegments);
const QString path = uri.path();
const QString localPath = uri.toLocalFile();
const bool isLocal = uri.isLocalFile();
if (uri.isEmpty())
......@@ -375,17 +375,17 @@ bool MainWindow::openUrl(const QUrl &u)
{
KMSG(i18n("The entered URL cannot be parsed; it is invalid."));
}
else if ((!isLocal && path[0] != QLatin1Char('/')) || (isLocal && !QDir::isAbsolutePath(path)))
else if ((!isLocal && localPath[0] != QLatin1Char('/')) || (isLocal && !QDir::isAbsolutePath(localPath)))
{
KMSG(i18n("Filelight only accepts absolute paths, eg. /%1", path));
KMSG(i18n("Filelight only accepts absolute paths, eg. /%1", localPath));
}
else if (isLocal && !QDir(path).exists())
else if (isLocal && !QDir(localPath).exists())
{
KMSG(i18n("Folder not found: %1", path));
KMSG(i18n("Folder not found: %1", localPath));
}
else if (isLocal && !QDir(path).isReadable())
else if (isLocal && !QDir(localPath).isReadable())
{
KMSG(i18n("Unable to enter: %1\nYou do not have access rights to this location.", path));
KMSG(i18n("Unable to enter: %1\nYou do not have access rights to this location.", localPath));
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment