diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index 7e0bb832f..3f8e3ea1b 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -350,6 +350,15 @@ void RevealFileInFinder(QString const& path) { } #endif // Q_OS_DARWIN +#ifdef Q_OS_WIN +void ShowFileInExplorer(QString const& path) { + // QUrl.toLocalFile() returns the path always with forward slashes, + // but the explorer needs two backslashes to navigate to the file. + QProcess::execute("explorer.exe", QStringList() << "/select," + << path.replace("/", "\\")); +} +#endif + void OpenInFileBrowser(const QList& urls) { QSet dirs; @@ -370,6 +379,8 @@ void OpenInFileBrowser(const QList& urls) { // revealing multiple files in the finder only opens one window, // so it also makes sense to reveal at most one per directory RevealFileInFinder(path); +#elif defined(Q_OS_WIN32) + ShowFileInExplorer(path); #else QDesktopServices::openUrl(QUrl::fromLocalFile(directory)); #endif