From e2f7380708cc580e73b91794ef12677a3acbe141 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Fri, 26 Apr 2019 20:47:23 +0200 Subject: [PATCH] ProjectExplorer: Add "Open Terminal Here" as default entry Most often, a terminal with system environment is needed. Provide it as direct context menu entry, and leave the additional entries for build and run environment (which are probably more seldom used) as sub-menu as before, but rename it to "Open Terminal with >". Change-Id: I148395ca1e62eafff8844ba91db269a12b053de9 Reviewed-by: Eike Ziller --- src/plugins/coreplugin/coreplugin.cpp | 2 +- .../editormanager/editormanager.cpp | 2 +- src/plugins/coreplugin/fileutils.cpp | 9 ++++++++- src/plugins/coreplugin/fileutils.h | 3 ++- src/plugins/coreplugin/systemsettings.cpp | 2 +- .../projectexplorer/projectexplorer.cpp | 19 +++++-------------- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 7f367331312..95398acc295 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -276,7 +276,7 @@ void CorePlugin::addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QM }); menu->insertAction(firstAction, showInGraphicalShell); - auto *showInTerminal = new QAction(Core::FileUtils::msgTerminalAction(), menu); + auto *showInTerminal = new QAction(Core::FileUtils::msgTerminalHereAction(), menu); connect(showInTerminal, &QAction::triggered, pathChooser, [pathChooser]() { Core::FileUtils::openTerminal(pathChooser->path()); }); diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 4d5bf55bb80..813d12739d0 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -214,7 +214,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_openTerminalAction(new QAction(FileUtils::msgTerminalAction(), this)), + m_openTerminalAction(new QAction(FileUtils::msgTerminalHereAction(), this)), m_findInDirectoryAction(new QAction(FileUtils::msgFindInDirectory(), this)), m_filePropertiesAction(new QAction(tr("Properties..."), this)), m_pinAction(new QAction(tr("Pin"), this)) diff --git a/src/plugins/coreplugin/fileutils.cpp b/src/plugins/coreplugin/fileutils.cpp index 02392cb8887..223cc70cf65 100644 --- a/src/plugins/coreplugin/fileutils.cpp +++ b/src/plugins/coreplugin/fileutils.cpp @@ -135,13 +135,20 @@ QString FileUtils::msgGraphicalShellAction() return QApplication::translate("Core::Internal", "Show Containing Folder"); } -QString FileUtils::msgTerminalAction() +QString FileUtils::msgTerminalHereAction() { if (HostOsInfo::isWindowsHost()) return QApplication::translate("Core::Internal", "Open Command Prompt Here"); return QApplication::translate("Core::Internal", "Open Terminal Here"); } +QString FileUtils::msgTerminalWithAction() +{ + if (HostOsInfo::isWindowsHost()) + return QApplication::translate("Core::Internal", "Open Command Prompt With"); + return QApplication::translate("Core::Internal", "Open Terminal With"); +} + void FileUtils::removeFile(const QString &filePath, bool deleteFromFS) { // remove from version control diff --git a/src/plugins/coreplugin/fileutils.h b/src/plugins/coreplugin/fileutils.h index c7746251c1e..0067d1d7285 100644 --- a/src/plugins/coreplugin/fileutils.h +++ b/src/plugins/coreplugin/fileutils.h @@ -44,7 +44,8 @@ struct CORE_EXPORT FileUtils static QString msgFindInDirectory(); // Platform-dependent action descriptions static QString msgGraphicalShellAction(); - static QString msgTerminalAction(); + static QString msgTerminalHereAction(); + static QString msgTerminalWithAction(); // File operations aware of version control and file system case-insensitiveness static void removeFile(const QString &filePath, bool deleteFromFS); static bool renameFile(const QString &from, const QString &to); diff --git a/src/plugins/coreplugin/systemsettings.cpp b/src/plugins/coreplugin/systemsettings.cpp index 7d072588a76..b6a435d36ab 100644 --- a/src/plugins/coreplugin/systemsettings.cpp +++ b/src/plugins/coreplugin/systemsettings.cpp @@ -68,7 +68,7 @@ QWidget *SystemSettings::widget() m_widget = new QWidget; m_page->setupUi(m_widget); m_page->terminalOpenArgs->setToolTip( - tr("Command line arguments used for \"%1\".").arg(FileUtils::msgTerminalAction())); + tr("Command line arguments used for \"%1\".").arg(FileUtils::msgTerminalHereAction())); m_page->reloadBehavior->setCurrentIndex(EditorManager::reloadSetting()); if (HostOsInfo::isAnyUnixHost()) { diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 8169fab0a0c..12eed68bd7c 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -835,13 +835,11 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er mfileContextMenu->appendGroup(Constants::G_PROJECT_TREE); // Open Terminal submenu -#if !defined(Q_OS_UNIX) || QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) ActionContainer * const openTerminal = ActionManager::createMenu(ProjectExplorer::Constants::M_OPENTERMINALCONTEXT); openTerminal->setOnAllDisabledBehavior(ActionContainer::Show); dd->m_openTerminalMenu = openTerminal->menu(); - dd->m_openTerminalMenu->setTitle(FileUtils::msgTerminalAction()); -#endif + dd->m_openTerminalMenu->setTitle(FileUtils::msgTerminalWithAction()); // "open with" submenu ActionContainer * const openWith = @@ -909,23 +907,16 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN); mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES); -#if !defined(Q_OS_UNIX) || QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // Open Terminal Here menu - mfileContextMenu->addMenu(openTerminal, Constants::G_FILE_OPEN); - mfolderContextMenu->addMenu(openTerminal, Constants::G_FOLDER_FILES); - - dd->m_openTerminalHere = new QAction(tr("System Environment"), this); - cmd = ActionManager::registerAction(dd->m_openTerminalHere, Constants::OPENTERMINALHERE, - projecTreeContext); - dd->m_openTerminalMenu->addAction(dd->m_openTerminalHere); -#else - dd->m_openTerminalHere = new QAction(FileUtils::msgTerminalAction(), this); + dd->m_openTerminalHere = new QAction(FileUtils::msgTerminalHereAction(), this); cmd = ActionManager::registerAction(dd->m_openTerminalHere, Constants::OPENTERMINALHERE, projecTreeContext); mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN); mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES); -#endif + + mfileContextMenu->addMenu(openTerminal, Constants::G_FILE_OPEN); + mfolderContextMenu->addMenu(openTerminal, Constants::G_FOLDER_FILES); dd->m_openTerminalHereBuildEnv = new QAction(tr("Build Environment"), this); dd->m_openTerminalHereRunEnv = new QAction(tr("Run Environment"), this);