diff --git a/dist/changes-1.3.0 b/dist/changes-1.3.0 index 8b6dd998ad9f0402b286a9d2937696d6f97ca17f..51b48427ba0429d5a0593ffeb790e7ec8de22efb 100644 --- a/dist/changes-1.3.0 +++ b/dist/changes-1.3.0 @@ -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 diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 7cc4087a8e40d7ad5daa3782ac915d6755a389c2..3c9ceb5971c27266e5db98ee953c2a9861fca6fd 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -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() { diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 126849a72e81b0f2e40298ec4528cff4dc559a68..c651e2f95320713294b0502f7b2d3a3e560d3de7 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -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; diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 6c67ddbd8f45e118f99f88c6b40f4009d4300cdc..222f83053622c7a6d9892fb532e3a5327bbed346 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -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";