forked from qt-creator/qt-creator
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:
@@ -93,18 +93,7 @@ void FileUtils::showInGraphicalShell(QWidget *parent, const FilePath &pathIn)
|
|||||||
param += QDir::toNativeSeparators(fileInfo.canonicalFilePath());
|
param += QDir::toNativeSeparators(fileInfo.canonicalFilePath());
|
||||||
QtcProcess::startDetached({explorer, param});
|
QtcProcess::startDetached({explorer, param});
|
||||||
} else if (HostOsInfo::isMacHost()) {
|
} else if (HostOsInfo::isMacHost()) {
|
||||||
QStringList scriptArgs;
|
QtcProcess::startDetached({"/usr/bin/open", {"-R", fileInfo.canonicalFilePath()}});
|
||||||
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();
|
|
||||||
} else {
|
} else {
|
||||||
// we cannot select a file here, because no file browser really supports it...
|
// we cannot select a file here, because no file browser really supports it...
|
||||||
const QString folder = fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.filePath();
|
const QString folder = fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.filePath();
|
||||||
|
Reference in New Issue
Block a user