forked from qt-creator/qt-creator
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:
@@ -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";
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user