diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index ff9e5d74bc88ff7104fc3575bba1a4d811e172e4..b4481b7773d2ab4ed050c42b2ee5b5660ef859df 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -414,6 +414,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er globalcontext); mfilec->addAction(cmd, Constants::G_FILE_OPEN); +#ifdef Q_OS_MAC + // Show in Finder action + m_showInFinder = new QAction(tr("Show in Finder..."), this); + cmd = am->registerAction(m_showInFinder, ProjectExplorer::Constants::SHOWINFINDER, + globalcontext); + mfilec->addAction(cmd, Constants::G_FILE_OPEN); +#endif + // Open With menu mfilec->addMenu(openWith, ProjectExplorer::Constants::G_FILE_OPEN); @@ -625,6 +633,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er connect(m_addNewFileAction, SIGNAL(triggered()), this, SLOT(addNewFile())); connect(m_addExistingFilesAction, SIGNAL(triggered()), this, SLOT(addExistingFiles())); connect(m_openFileAction, SIGNAL(triggered()), this, SLOT(openFile())); +#ifdef Q_OS_MAC + connect(m_showInFinder, SIGNAL(triggered()), this, SLOT(showInFinder())); +#endif connect(m_removeFileAction, SIGNAL(triggered()), this, SLOT(removeFile())); connect(m_renameFileAction, SIGNAL(triggered()), this, SLOT(renameFile())); @@ -1625,6 +1636,21 @@ void ProjectExplorerPlugin::openFile() em->ensureEditorManagerVisible(); } +#ifdef Q_OS_MAC +void ProjectExplorerPlugin::showInFinder() +{ + if (!m_currentNode) + return; + QProcess::execute("/usr/bin/osascript", QStringList() + << "-e" + << QString("tell application \"Finder\" to reveal POSIX file \"%1\"") + .arg(m_currentNode->path())); + QProcess::execute("/usr/bin/osascript", QStringList() + << "-e" + << "tell application \"Finder\" to activate"); +} +#endif + void ProjectExplorerPlugin::removeFile() { if (!m_currentNode && m_currentNode->nodeType() == FileNodeType) diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index b8f55ff3e55a7bbf826d9c2c2491ea1cdd657b94..83581ec1b0f5b81ba0b8486047b626e47b6a40f5 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -157,6 +157,9 @@ private slots: void addNewFile(); void addExistingFiles(); void openFile(); +#ifdef Q_OS_MAC + void showInFinder(); +#endif void removeFile(); void renameFile(); @@ -225,6 +228,9 @@ private: QAction *m_addNewFileAction; QAction *m_addExistingFilesAction; QAction *m_openFileAction; +#ifdef Q_OS_MAC + QAction *m_showInFinder; +#endif QAction *m_removeFileAction; QAction *m_renameFileAction; diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 8c854349a851ae1284a1b82b98eafeda162268fa..77ea8d8292e022b113e0a7955d05c0b5b7749acc 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -63,6 +63,7 @@ const char * const SHOWPROPERTIES = "ProjectExplorer.ShowProperties"; const char * const ADDNEWFILE = "ProjectExplorer.AddNewFile"; const char * const ADDEXISTINGFILES = "ProjectExplorer.AddExistingFiles"; const char * const OPENFILE = "ProjectExplorer.OpenFile"; +const char * const SHOWINFINDER = "ProjectExplorer.ShowInFinder"; const char * const REMOVEFILE = "ProjectExplorer.RemoveFile"; const char * const RENAMEFILE = "ProjectExplorer.RenameFile";