diff --git a/src/plugins/coreplugin/coreconstants.h b/src/plugins/coreplugin/coreconstants.h index d34886632fe..8e4b8af366e 100644 --- a/src/plugins/coreplugin/coreconstants.h +++ b/src/plugins/coreplugin/coreconstants.h @@ -134,6 +134,7 @@ const char GOTOLASTEDIT[] = "QtCreator.GotoLastEdit"; const char ABOUT_QTCREATOR[] = "QtCreator.AboutQtCreator"; const char ABOUT_PLUGINS[] = "QtCreator.AboutPlugins"; const char S_RETURNTOEDITOR[] = "QtCreator.ReturnToEditor"; +const char SHOWINGRAPHICALSHELL[] = "QtCreator.ShowInGraphicalShell"; // Default groups const char G_DEFAULT_ONE[] = "QtCreator.Group.Default.One"; diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index bf7e3ff0821..1731f6698be 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -420,6 +420,7 @@ EditorManagerPrivate::EditorManagerPrivate(QObject *parent) : m_closeOtherDocumentsContextAction(new QAction(EditorManager::tr("Close Others"), this)), m_closeAllEditorsExceptVisibleContextAction(new QAction(EditorManager::tr("Close All Except Visible"), this)), m_openGraphicalShellAction(new QAction(FileUtils::msgGraphicalShellAction(), this)), + m_openGraphicalShellContextAction(new QAction(FileUtils::msgGraphicalShellAction(), this)), m_openTerminalAction(new QAction(FileUtils::msgTerminalHereAction(), this)), m_findInDirectoryAction(new QAction(FileUtils::msgFindInDirectory(), this)), m_filePropertiesAction(new QAction(tr("Properties..."), this)), @@ -521,8 +522,21 @@ void EditorManagerPrivate::init() // Close All Others Except Visible Action cmd = ActionManager::registerAction(m_closeAllEditorsExceptVisibleAction, Constants::CLOSEALLEXCEPTVISIBLE, editManagerContext, true); mfile->addAction(cmd, Constants::G_FILE_CLOSE); - connect(m_closeAllEditorsExceptVisibleAction, &QAction::triggered, - this, &EditorManagerPrivate::closeAllEditorsExceptVisible); + connect(m_closeAllEditorsExceptVisibleAction, + &QAction::triggered, + this, + &EditorManagerPrivate::closeAllEditorsExceptVisible); + + cmd = ActionManager::registerAction(m_openGraphicalShellAction, + Constants::SHOWINGRAPHICALSHELL, + editManagerContext); + connect(m_openGraphicalShellAction, &QAction::triggered, this, [] { + if (!EditorManager::currentDocument()) + return; + const FilePath fp = EditorManager::currentDocument()->filePath(); + if (!fp.isEmpty()) + FileUtils::showInGraphicalShell(ICore::dialogParent(), fp.toString()); + }); //Save XXX Context Actions connect(m_copyFilePathContextAction, &QAction::triggered, @@ -548,8 +562,12 @@ void EditorManagerPrivate::init() connect(m_closeAllEditorsExceptVisibleContextAction, &QAction::triggered, this, &EditorManagerPrivate::closeAllEditorsExceptVisible); - connect(m_openGraphicalShellAction, &QAction::triggered, - this, &EditorManagerPrivate::showInGraphicalShell); + connect(m_openGraphicalShellContextAction, &QAction::triggered, this, [this] { + if (!m_contextMenuEntry || m_contextMenuEntry->fileName().isEmpty()) + return; + FileUtils::showInGraphicalShell(ICore::dialogParent(), + m_contextMenuEntry->fileName().toString()); + }); connect(m_openTerminalAction, &QAction::triggered, this, &EditorManagerPrivate::openTerminal); connect(m_findInDirectoryAction, &QAction::triggered, this, &EditorManagerPrivate::findInDirectory); @@ -2564,14 +2582,6 @@ void EditorManagerPrivate::autoSuspendDocuments() closeEditors(DocumentModel::editorsForDocuments(documentsToSuspend), CloseFlag::Suspend); } -void EditorManagerPrivate::showInGraphicalShell() -{ - if (!d->m_contextMenuEntry || d->m_contextMenuEntry->fileName().isEmpty()) - return; - FileUtils::showInGraphicalShell(ICore::dialogParent(), - d->m_contextMenuEntry->fileName().toString()); -} - void EditorManagerPrivate::openTerminal() { if (!d->m_contextMenuEntry || d->m_contextMenuEntry->fileName().isEmpty()) @@ -2864,11 +2874,11 @@ void EditorManager::addNativeDirAndOpenWithActions(QMenu *contextMenu, DocumentM QTC_ASSERT(contextMenu, return); d->m_contextMenuEntry = entry; bool enabled = entry && !entry->fileName().isEmpty(); - d->m_openGraphicalShellAction->setEnabled(enabled); + d->m_openGraphicalShellContextAction->setEnabled(enabled); d->m_openTerminalAction->setEnabled(enabled); d->m_findInDirectoryAction->setEnabled(enabled); d->m_filePropertiesAction->setEnabled(enabled); - contextMenu->addAction(d->m_openGraphicalShellAction); + contextMenu->addAction(d->m_openGraphicalShellContextAction); contextMenu->addAction(d->m_openTerminalAction); contextMenu->addAction(d->m_findInDirectoryAction); contextMenu->addAction(d->m_filePropertiesAction); diff --git a/src/plugins/coreplugin/editormanager/editormanager_p.h b/src/plugins/coreplugin/editormanager/editormanager_p.h index b173f6b2cb6..c65526db7f7 100644 --- a/src/plugins/coreplugin/editormanager/editormanager_p.h +++ b/src/plugins/coreplugin/editormanager/editormanager_p.h @@ -182,7 +182,6 @@ private: static void revertToSaved(IDocument *document); static void autoSuspendDocuments(); - static void showInGraphicalShell(); static void openTerminal(); static void findInDirectory(); @@ -258,6 +257,7 @@ private: QAction *m_closeOtherDocumentsContextAction; QAction *m_closeAllEditorsExceptVisibleContextAction; QAction *m_openGraphicalShellAction; + QAction *m_openGraphicalShellContextAction; QAction *m_openTerminalAction; QAction *m_findInDirectoryAction; QAction *m_filePropertiesAction = nullptr; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 90666ef946e..5e73e5ec68d 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -232,7 +232,6 @@ const char ADDNEWSUBPROJECT[] = "ProjectExplorer.AddNewSubproject"; const char REMOVEPROJECT[] = "ProjectExplorer.RemoveProject"; const char OPENFILE[] = "ProjectExplorer.OpenFile"; const char SEARCHONFILESYSTEM[] = "ProjectExplorer.SearchOnFileSystem"; -const char SHOWINGRAPHICALSHELL[] = "ProjectExplorer.ShowInGraphicalShell"; const char OPENTERMINALHERE[] = "ProjectExplorer.OpenTerminalHere"; const char DUPLICATEFILE[] = "ProjectExplorer.DuplicateFile"; const char DELETEFILE[] = "ProjectExplorer.DeleteFile"; @@ -1015,8 +1014,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST); dd->m_showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), this); - cmd = ActionManager::registerAction(dd->m_showInGraphicalShell, Constants::SHOWINGRAPHICALSHELL, - projectTreeContext); + cmd = ActionManager::registerAction(dd->m_showInGraphicalShell, + Core::Constants::SHOWINGRAPHICALSHELL, + projectTreeContext); mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN); mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);