1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 02:32:29 +01:00

Use old method on Windows of opening a folder

This commit is contained in:
Elias Steurer 2023-01-05 14:37:14 +01:00
parent cc4cda5aa0
commit c743fd7377

View File

@ -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));
}