forked from qt-creator/qt-creator
Extend "Show in Finder" functionality to Windows and Unix.
On Unix, we cannot select the specific file, so the entry there is called "Open containing folder".
This commit is contained in:
4
dist/changes-1.3.0
vendored
4
dist/changes-1.3.0
vendored
@@ -49,9 +49,11 @@ Project support
|
||||
* By default projects using the Microsoft Visual Studio toolchain use jom
|
||||
instead of nmake, for better utilization of all processors.
|
||||
* Show subdirectory structure below .pro/.pri files in project tree
|
||||
* Add "Show file in Finder/Explorer" (Mac/Windows) to context menu.
|
||||
On Linux it opens the containing directory.
|
||||
|
||||
Compilation
|
||||
* Support distributed compilation on Windows/MSVC via jom
|
||||
* Support multi-core compilation on Windows/MSVC via jom
|
||||
(see http://qt.gitorious.org/qt-labs/jom/)
|
||||
|
||||
Debugging
|
||||
|
@@ -420,14 +420,17 @@ 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,
|
||||
#if defined(Q_OS_WIN)
|
||||
m_showInGraphicalShell = new QAction(tr("Show in Explorer..."), this);
|
||||
#elif defined(Q_OS_MAC)
|
||||
m_showInGraphicalShell = new QAction(tr("Show in Finder..."), this);
|
||||
#else
|
||||
m_showInGraphicalShell = new QAction(tr("Show containing folder..."), this);
|
||||
#endif
|
||||
cmd = am->registerAction(m_showInGraphicalShell, ProjectExplorer::Constants::SHOWINGRAPHICALSHELL,
|
||||
globalcontext);
|
||||
mfilec->addAction(cmd, Constants::G_FILE_OPEN);
|
||||
mfolder->addAction(cmd, Constants::G_FOLDER_FILES);
|
||||
#endif
|
||||
|
||||
// Open With menu
|
||||
mfilec->addMenu(openWith, ProjectExplorer::Constants::G_FILE_OPEN);
|
||||
@@ -681,9 +684,7 @@ 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_showInGraphicalShell, SIGNAL(triggered()), this, SLOT(showInGraphicalShell()));
|
||||
connect(m_removeFileAction, SIGNAL(triggered()), this, SLOT(removeFile()));
|
||||
connect(m_renameFileAction, SIGNAL(triggered()), this, SLOT(renameFile()));
|
||||
|
||||
@@ -1751,10 +1752,21 @@ void ProjectExplorerPlugin::openFile()
|
||||
em->ensureEditorManagerVisible();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void ProjectExplorerPlugin::showInFinder()
|
||||
void ProjectExplorerPlugin::showInGraphicalShell()
|
||||
{
|
||||
QTC_ASSERT(m_currentNode, return)
|
||||
#if defined(Q_OS_WIN)
|
||||
QString explorer = Environment::systemEnvironment().searchInPath("explorer.exe");
|
||||
if (explorer.isEmpty()) {
|
||||
QMessageBox::warning(Core::ICore::instance()->mainWindow(),
|
||||
tr("Launching Windows Explorer failed"),
|
||||
tr("Could not find explorer.exe in path to launch Windows Explorer."));
|
||||
return;
|
||||
}
|
||||
QProcess::execute(explorer,
|
||||
QStringList() << QString("/select,%1")
|
||||
.arg(QDir::toNativeSeparators(m_currentNode->path())));
|
||||
#elif defined(Q_OS_MAC)
|
||||
QProcess::execute("/usr/bin/osascript", QStringList()
|
||||
<< "-e"
|
||||
<< QString("tell application \"Finder\" to reveal POSIX file \"%1\"")
|
||||
@@ -1762,8 +1774,19 @@ void ProjectExplorerPlugin::showInFinder()
|
||||
QProcess::execute("/usr/bin/osascript", QStringList()
|
||||
<< "-e"
|
||||
<< "tell application \"Finder\" to activate");
|
||||
#elif
|
||||
// we cannot select a file here, because no file browser really supports it...
|
||||
QFileInfo fileInfo(m_currentNode->path());
|
||||
QString xdgopen = Environment::systemEnvironment().searchInPath("xdg-open");
|
||||
if (xdgopen.isEmpty()) {
|
||||
QMessageBox::warning(Core::ICore::instance()->mainWindow(),
|
||||
tr("Launching a file explorer failed"),
|
||||
tr("Could not find xdg-open to launch the native file explorer."));
|
||||
return;
|
||||
}
|
||||
QProcess::execute(xdgopen, QStringList() << fileInfo.path());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProjectExplorerPlugin::removeFile()
|
||||
{
|
||||
|
@@ -184,8 +184,8 @@ private slots:
|
||||
void addNewFile();
|
||||
void addExistingFiles();
|
||||
void openFile();
|
||||
#ifdef Q_OS_MAC
|
||||
void showInFinder();
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
void showInGraphicalShell();
|
||||
#endif
|
||||
void removeFile();
|
||||
void renameFile();
|
||||
@@ -257,8 +257,8 @@ private:
|
||||
QAction *m_addNewFileAction;
|
||||
QAction *m_addExistingFilesAction;
|
||||
QAction *m_openFileAction;
|
||||
#ifdef Q_OS_MAC
|
||||
QAction *m_showInFinder;
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
QAction *m_showInGraphicalShell;
|
||||
#endif
|
||||
QAction *m_removeFileAction;
|
||||
QAction *m_renameFileAction;
|
||||
|
@@ -66,7 +66,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 SHOWINGRAPHICALSHELL = "ProjectExplorer.ShowInGraphicalShell";
|
||||
const char * const REMOVEFILE = "ProjectExplorer.RemoveFile";
|
||||
const char * const RENAMEFILE = "ProjectExplorer.RenameFile";
|
||||
|
||||
|
Reference in New Issue
Block a user