macOS: Use "open -R" for showing files in Finder

Instead of using AppleScript. Available since at least macOS 10.13.

Change-Id: I088efc211189aab75480b3ea02f90cc235724bef
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Eike Ziller
2022-01-18 15:37:42 +01:00
parent 57666c2a49
commit 2499b88966

View File

@@ -93,18 +93,7 @@ void FileUtils::showInGraphicalShell(QWidget *parent, const FilePath &pathIn)
param += QDir::toNativeSeparators(fileInfo.canonicalFilePath());
QtcProcess::startDetached({explorer, param});
} else if (HostOsInfo::isMacHost()) {
QStringList scriptArgs;
scriptArgs << QLatin1String("-e")
<< QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
.arg(fileInfo.canonicalFilePath());
QtcProcess osascriptProcess;
osascriptProcess.setCommand({"/usr/bin/osascript", scriptArgs});
osascriptProcess.runBlocking();
scriptArgs.clear();
scriptArgs << QLatin1String("-e")
<< QLatin1String("tell application \"Finder\" to activate");
osascriptProcess.setCommand({"/usr/bin/osascript", scriptArgs});
osascriptProcess.runBlocking();
QtcProcess::startDetached({"/usr/bin/open", {"-R", fileInfo.canonicalFilePath()}});
} else {
// we cannot select a file here, because no file browser really supports it...
const QString folder = fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.filePath();