From c743fd737795301cb070899cc9e4fd84ae2059bd Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Thu, 5 Jan 2023 14:37:14 +0100 Subject: [PATCH] Use old method on Windows of opening a folder --- ScreenPlay/src/util.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ScreenPlay/src/util.cpp b/ScreenPlay/src/util.cpp index 67f85e16..2bf30066 100644 --- a/ScreenPlay/src/util.cpp +++ b/ScreenPlay/src/util.cpp @@ -95,6 +95,21 @@ bool Util::writeJsonObjectToFile(const QString& absoluteFilePath, const QJsonObj void Util::openFolderInExplorer(const QString& url) const { const QString path = QUrl::fromUserInput(url).toLocalFile(); + + // QDesktopServices can hang on Windows + if (QSysInfo::productType() == "windows") { + QProcess explorer; + explorer.setProgram("explorer.exe"); + // When we have space in the path like + // C:\Program Files (x86)\Steam\... + // we cannot set the path as an argument. But we can set the working it + // to the wanted path and open the current path via the dot. + explorer.setWorkingDirectory(QDir::toNativeSeparators(path)); + explorer.setArguments({ "." }); + explorer.startDetached(); + return; + } + QDesktopServices::openUrl(QUrl::fromLocalFile(path)); }