1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-18 08:22:33 +02:00

Fix opening folder on macos

This commit is contained in:
Elias Steurer 2020-04-25 11:08:18 +02:00
parent 36644ba12d
commit 0575c30c25

View File

@ -201,11 +201,9 @@ std::optional<QJsonObject> Util::parseQByteArrayToQJsonObject(const QByteArray&
void Util::openFolderInExplorer(const QString& url) const
{
QString fileString { "file:///" };
QString parameter = url;
if (url.contains(fileString)) {
parameter.remove(fileString);
}
QString path = QUrl::fromUserInput(url).toLocalFile();
QProcess explorer;
#ifdef Q_OS_WIN
explorer.setProgram("explorer.exe");
@ -213,11 +211,11 @@ void Util::openFolderInExplorer(const QString& url) const
// 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(parameter));
explorer.setWorkingDirectory(QDir::toNativeSeparators(path));
explorer.setArguments({ "." });
#elif defined(Q_OS_OSX)
explorer.setProgram("open");
explorer.setArguments({ QDir::toNativeSeparators(parameter) });
explorer.setArguments({ QDir::toNativeSeparators(path) });
#endif
explorer.startDetached();