From 457ef620a94770a55dc291533efbf4d9b31a6364 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 17 Oct 2015 20:12:47 +0200 Subject: [PATCH] GUI: properly construct a file:// URL when opening the output folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GUI tells Qt to open a directory like e.g. "file:////home/mosu/…". Two slashes are needed for the protocol, one for the root folder, and the fourth one is superfluous. Now file managers like Windows Explorer or krusader simply open a directory name called "//home/mosu/…" – that works. But others like Dolphin try to be smart, see that the file name starts with "//…" and think the user wants to visit a share called "mosu" on a Samba/Windows server called "home". Then they prepend the whole URL with "smb://". On Windows the third slash is actually needed when letting Qt parse such a URL. So instead of using #ifdefs create an empty URL and set the scheme and the path components explicitly and don't let Qt parse a stringified URL. Fixes #1479. --- ChangeLog | 7 +++++++ src/mkvtoolnix-gui/jobs/job.cpp | 3 ++- src/mkvtoolnix-gui/util/file.cpp | 10 ++++++++++ src/mkvtoolnix-gui/util/file.h | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 21e34bb07..a9eb48033 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2015-10-17 Moritz Bunkus + * MKVToolNix GUI: bug fix (Linux): the function "open folder" was + inserting a superfluous leading slash in the directory name. This + causes some file managers (in this particular case Dolphin on + Linux) to interpret a directory name like "//home/mosu/…" as a + share called "mosu" on a Samba/Windows server called "home" and to + prepend the whole name with the "smb://" protocol. Fixes #1479. + * Released v8.5.0. 2015-10-16 Moritz Bunkus diff --git a/src/mkvtoolnix-gui/jobs/job.cpp b/src/mkvtoolnix-gui/jobs/job.cpp index c78629e32..119fd80e5 100644 --- a/src/mkvtoolnix-gui/jobs/job.cpp +++ b/src/mkvtoolnix-gui/jobs/job.cpp @@ -9,6 +9,7 @@ #include "mkvtoolnix-gui/jobs/job.h" #include "mkvtoolnix-gui/jobs/mux_job.h" #include "mkvtoolnix-gui/util/config_file.h" +#include "mkvtoolnix-gui/util/file.h" #include "mkvtoolnix-gui/util/settings.h" namespace mtx { namespace gui { namespace Jobs { @@ -246,7 +247,7 @@ Job::openOutputFolder() auto folder = outputFolder(); if (!folder.isEmpty()) - QDesktopServices::openUrl(QUrl{Q("file:///%1").arg(folder)}); + QDesktopServices::openUrl(Util::pathToFileUrl(folder)); } QString diff --git a/src/mkvtoolnix-gui/util/file.cpp b/src/mkvtoolnix-gui/util/file.cpp index a6f1a72e1..274a68021 100644 --- a/src/mkvtoolnix-gui/util/file.cpp +++ b/src/mkvtoolnix-gui/util/file.cpp @@ -3,7 +3,9 @@ #include #include #include +#include +#include "common/qt.h" #include "mkvtoolnix-gui/util/file.h" namespace mtx { namespace gui { namespace Util { @@ -38,4 +40,12 @@ checkForBomAndNonAscii(QString const &fileName) { return result; } +QUrl +pathToFileUrl(QString const &path) { + auto url = QUrl{}; + url.setScheme(Q("file")); + url.setPath(path); + return url; +} + }}} diff --git a/src/mkvtoolnix-gui/util/file.h b/src/mkvtoolnix-gui/util/file.h index 88a7877ba..8360edd49 100644 --- a/src/mkvtoolnix-gui/util/file.h +++ b/src/mkvtoolnix-gui/util/file.h @@ -4,6 +4,7 @@ #include "common/common_pch.h" class QString; +class QUrl; namespace mtx { namespace gui { namespace Util { @@ -15,6 +16,8 @@ struct BomAsciiCheckResult { BomAsciiCheckResult checkForBomAndNonAscii(QString const &fileName); +QUrl pathToFileUrl(QString const &path); + }}} #endif // MTX_MKVTOOLNIX_GUI_UTIL_FILE_H