Commit 5dc74a98 authored by con's avatar con

Add 'Show in Finder' context menu.

Task:     248454
parent 3a4412c3
......@@ -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)
......
......@@ -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;
......
......@@ -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";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment