Make it possible to assign global shortcut to "Show in Explorer/Finder"

So it works consistently for the project tree and when in editors.
The action ID changes from ProjectExplorer.ShowInGraphicalShell to
QtCreator.ShowInGraphicalShell.

Fixes: QTCREATORBUG-24958
Change-Id: I4c89e61997183401080dd64e66c4fec681b53241
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2021-01-18 15:25:14 +01:00
parent def68ecd2f
commit 0fa391c7d3
4 changed files with 29 additions and 18 deletions

View File

@@ -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";

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);