summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-10-02 08:48:05 +0200
committerAndy Shaw <andy.shaw@qt.io>2018-04-06 12:45:02 +0000
commitd90fb72c201efde8f9fc10c4fb4a542b1a26b9e8 (patch)
tree6eec98b35eb083f512fd43820032fac346fb37c3 /src/gui/util
parentec23d96c86b43046cd2456829aca763ea6ba9935 (diff)
Pass on local html links with a fragment to openUrl()
If a file link to a html file has a fragment part included then this will be lost when passed to QDesktopServices::openUrl() as this is not kept in the conversion of the QUrl. So by checking the filename in the case of a fragment existing in the url, we can be sure that the information is passed on correctly for html files. Task-number: QTBUG-14460 Change-Id: I8167d8c164713dd999603ba9e74150f4f1a4abea Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/gui/util')
-rw-r--r--src/gui/util/qdesktopservices.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
index 77ccc02aa5..dfd190ddd0 100644
--- a/src/gui/util/qdesktopservices.cpp
+++ b/src/gui/util/qdesktopservices.cpp
@@ -226,8 +226,11 @@ bool QDesktopServices::openUrl(const QUrl &url)
qWarning("The platform plugin does not support services.");
return false;
}
- return url.scheme() == QLatin1String("file") ?
- platformServices->openDocument(url) : platformServices->openUrl(url);
+ // We only use openDocument if there is no fragment for the URL to
+ // avoid it being lost when using openDocument
+ if (url.isLocalFile() && !url.hasFragment())
+ return platformServices->openDocument(url);
+ return platformServices->openUrl(url);
}
/*!