forked from qt-creator/qt-creator
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 <eike.ziller@qt.io>
This commit is contained in:
committed by
Eike Ziller
parent
504e0140bb
commit
e2f7380708
@@ -276,7 +276,7 @@ void CorePlugin::addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QM
|
|||||||
});
|
});
|
||||||
menu->insertAction(firstAction, showInGraphicalShell);
|
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]() {
|
connect(showInTerminal, &QAction::triggered, pathChooser, [pathChooser]() {
|
||||||
Core::FileUtils::openTerminal(pathChooser->path());
|
Core::FileUtils::openTerminal(pathChooser->path());
|
||||||
});
|
});
|
||||||
|
@@ -214,7 +214,7 @@ EditorManagerPrivate::EditorManagerPrivate(QObject *parent) :
|
|||||||
m_closeOtherDocumentsContextAction(new QAction(EditorManager::tr("Close Others"), this)),
|
m_closeOtherDocumentsContextAction(new QAction(EditorManager::tr("Close Others"), this)),
|
||||||
m_closeAllEditorsExceptVisibleContextAction(new QAction(EditorManager::tr("Close All Except Visible"), this)),
|
m_closeAllEditorsExceptVisibleContextAction(new QAction(EditorManager::tr("Close All Except Visible"), this)),
|
||||||
m_openGraphicalShellAction(new QAction(FileUtils::msgGraphicalShellAction(), 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_findInDirectoryAction(new QAction(FileUtils::msgFindInDirectory(), this)),
|
||||||
m_filePropertiesAction(new QAction(tr("Properties..."), this)),
|
m_filePropertiesAction(new QAction(tr("Properties..."), this)),
|
||||||
m_pinAction(new QAction(tr("Pin"), this))
|
m_pinAction(new QAction(tr("Pin"), this))
|
||||||
|
@@ -135,13 +135,20 @@ QString FileUtils::msgGraphicalShellAction()
|
|||||||
return QApplication::translate("Core::Internal", "Show Containing Folder");
|
return QApplication::translate("Core::Internal", "Show Containing Folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FileUtils::msgTerminalAction()
|
QString FileUtils::msgTerminalHereAction()
|
||||||
{
|
{
|
||||||
if (HostOsInfo::isWindowsHost())
|
if (HostOsInfo::isWindowsHost())
|
||||||
return QApplication::translate("Core::Internal", "Open Command Prompt Here");
|
return QApplication::translate("Core::Internal", "Open Command Prompt Here");
|
||||||
return QApplication::translate("Core::Internal", "Open Terminal 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)
|
void FileUtils::removeFile(const QString &filePath, bool deleteFromFS)
|
||||||
{
|
{
|
||||||
// remove from version control
|
// remove from version control
|
||||||
|
@@ -44,7 +44,8 @@ struct CORE_EXPORT FileUtils
|
|||||||
static QString msgFindInDirectory();
|
static QString msgFindInDirectory();
|
||||||
// Platform-dependent action descriptions
|
// Platform-dependent action descriptions
|
||||||
static QString msgGraphicalShellAction();
|
static QString msgGraphicalShellAction();
|
||||||
static QString msgTerminalAction();
|
static QString msgTerminalHereAction();
|
||||||
|
static QString msgTerminalWithAction();
|
||||||
// File operations aware of version control and file system case-insensitiveness
|
// File operations aware of version control and file system case-insensitiveness
|
||||||
static void removeFile(const QString &filePath, bool deleteFromFS);
|
static void removeFile(const QString &filePath, bool deleteFromFS);
|
||||||
static bool renameFile(const QString &from, const QString &to);
|
static bool renameFile(const QString &from, const QString &to);
|
||||||
|
@@ -68,7 +68,7 @@ QWidget *SystemSettings::widget()
|
|||||||
m_widget = new QWidget;
|
m_widget = new QWidget;
|
||||||
m_page->setupUi(m_widget);
|
m_page->setupUi(m_widget);
|
||||||
m_page->terminalOpenArgs->setToolTip(
|
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());
|
m_page->reloadBehavior->setCurrentIndex(EditorManager::reloadSetting());
|
||||||
if (HostOsInfo::isAnyUnixHost()) {
|
if (HostOsInfo::isAnyUnixHost()) {
|
||||||
|
@@ -835,13 +835,11 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
mfileContextMenu->appendGroup(Constants::G_PROJECT_TREE);
|
mfileContextMenu->appendGroup(Constants::G_PROJECT_TREE);
|
||||||
|
|
||||||
// Open Terminal submenu
|
// Open Terminal submenu
|
||||||
#if !defined(Q_OS_UNIX) || QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
||||||
ActionContainer * const openTerminal =
|
ActionContainer * const openTerminal =
|
||||||
ActionManager::createMenu(ProjectExplorer::Constants::M_OPENTERMINALCONTEXT);
|
ActionManager::createMenu(ProjectExplorer::Constants::M_OPENTERMINALCONTEXT);
|
||||||
openTerminal->setOnAllDisabledBehavior(ActionContainer::Show);
|
openTerminal->setOnAllDisabledBehavior(ActionContainer::Show);
|
||||||
dd->m_openTerminalMenu = openTerminal->menu();
|
dd->m_openTerminalMenu = openTerminal->menu();
|
||||||
dd->m_openTerminalMenu->setTitle(FileUtils::msgTerminalAction());
|
dd->m_openTerminalMenu->setTitle(FileUtils::msgTerminalWithAction());
|
||||||
#endif
|
|
||||||
|
|
||||||
// "open with" submenu
|
// "open with" submenu
|
||||||
ActionContainer * const openWith =
|
ActionContainer * const openWith =
|
||||||
@@ -909,23 +907,16 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
|
mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
|
||||||
mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
|
mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
|
||||||
|
|
||||||
#if !defined(Q_OS_UNIX) || QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
||||||
// Open Terminal Here menu
|
// Open Terminal Here menu
|
||||||
mfileContextMenu->addMenu(openTerminal, Constants::G_FILE_OPEN);
|
dd->m_openTerminalHere = new QAction(FileUtils::msgTerminalHereAction(), this);
|
||||||
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);
|
|
||||||
cmd = ActionManager::registerAction(dd->m_openTerminalHere, Constants::OPENTERMINALHERE,
|
cmd = ActionManager::registerAction(dd->m_openTerminalHere, Constants::OPENTERMINALHERE,
|
||||||
projecTreeContext);
|
projecTreeContext);
|
||||||
|
|
||||||
mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
|
mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
|
||||||
mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
|
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_openTerminalHereBuildEnv = new QAction(tr("Build Environment"), this);
|
||||||
dd->m_openTerminalHereRunEnv = new QAction(tr("Run Environment"), this);
|
dd->m_openTerminalHereRunEnv = new QAction(tr("Run Environment"), this);
|
||||||
|
Reference in New Issue
Block a user