ProjectExplorer: Add shortcut for switching active project

... when in project mode.
We re-use the "GotoPreviousInHistory" action, which is semantically not
equivalent, but still seems like the most natural fit.

Fixes: QTCREATORBUG-19719
Change-Id: If00a90ce93ac3bd7e079d47eefa69e4f4aeb30cb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Kandeler
2019-11-13 12:53:26 +01:00
parent e097323817
commit 58da82835b
3 changed files with 13 additions and 3 deletions

View File

@@ -234,9 +234,6 @@ const char SELECTTARGETQUICK[] = "ProjectExplorer.SelectTargetQuick";
const int P_ACTION_RUN = 100;
const int P_ACTION_BUILDPROJECT = 80;
// Context
const char C_PROJECTEXPLORER[] = "Project Explorer";
// Menus
const char M_RECENTPROJECTS[] = "ProjectExplorer.Menu.Recent";
const char M_UNLOADPROJECTS[] = "ProjectExplorer.Menu.Unload";

View File

@@ -42,6 +42,7 @@ const char RENAMEFILE[] = "ProjectExplorer.RenameFile";
const char REMOVEFILE[] = "ProjectExplorer.RemoveFile";
// Context
const char C_PROJECTEXPLORER[] = "Project Explorer";
const char C_PROJECT_TREE[] = "ProjectExplorer.ProjectTreeContext";
// Menus

View File

@@ -26,6 +26,7 @@
#include "projectwindow.h"
#include "buildinfo.h"
#include "projectexplorerconstants.h"
#include "kit.h"
#include "kitmanager.h"
#include "kitoptionspage.h"
@@ -38,6 +39,9 @@
#include "target.h"
#include "targetsettingspanel.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icontext.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/coreicons.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
@@ -377,6 +381,14 @@ public:
connect(m_projectSelection, QOverload<int>::of(&QComboBox::activated),
this, &ProjectWindowPrivate::projectSelected, Qt::QueuedConnection);
const auto switchProjectAction = new QAction(this);
ActionManager::registerAction(switchProjectAction, Core::Constants::GOTOPREVINHISTORY,
Context(Constants::C_PROJECTEXPLORER));
connect(switchProjectAction, &QAction::triggered, this, [this] {
if (m_projectSelection->count() > 1)
m_projectSelection->showPopup();
});
SessionManager *sessionManager = SessionManager::instance();
connect(sessionManager, &SessionManager::projectAdded,
this, &ProjectWindowPrivate::registerProject);