ProjectExplorer: Fix context menu actions

Disable/Enable them correctly and give them the correct context.

Task-Nr: QTCREATORBUG-3078
This commit is contained in:
dt
2010-11-12 17:25:39 +01:00
parent c0a0c61050
commit 74d641a8d1
4 changed files with 98 additions and 80 deletions

View File

@@ -279,6 +279,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::Context pecontext(Constants::C_PROJECTEXPLORER); Core::Context pecontext(Constants::C_PROJECTEXPLORER);
Core::Context projecTreeContext(Constants::C_PROJECT_TREE);
d->m_projectsMode = new Core::BaseMode; d->m_projectsMode = new Core::BaseMode;
d->m_projectsMode->setDisplayName(tr("Projects")); d->m_projectsMode->setDisplayName(tr("Projects"));
@@ -342,20 +343,20 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// context menus // context menus
Core::ActionContainer *msessionContextMenu = Core::ActionContainer *msessionContextMenu =
am->createMenu(Constants::M_SESSIONCONTEXT); am->createMenu(Constants::M_SESSIONCONTEXT);
Core::ActionContainer *mproject = Core::ActionContainer *mprojectContextMenu =
am->createMenu(Constants::M_PROJECTCONTEXT); am->createMenu(Constants::M_PROJECTCONTEXT);
Core::ActionContainer *msubProject = Core::ActionContainer *msubProjectContextMenu =
am->createMenu(Constants::M_SUBPROJECTCONTEXT); am->createMenu(Constants::M_SUBPROJECTCONTEXT);
Core::ActionContainer *mfolder = Core::ActionContainer *mfolderContextMenu =
am->createMenu(Constants::M_FOLDERCONTEXT); am->createMenu(Constants::M_FOLDERCONTEXT);
Core::ActionContainer *mfilec = Core::ActionContainer *mfileContextMenu =
am->createMenu(Constants::M_FILECONTEXT); am->createMenu(Constants::M_FILECONTEXT);
d->m_sessionContextMenu = msessionContextMenu->menu(); d->m_sessionContextMenu = msessionContextMenu->menu();
d->m_projectMenu = mproject->menu(); d->m_projectMenu = mprojectContextMenu->menu();
d->m_subProjectMenu = msubProject->menu(); d->m_subProjectMenu = msubProjectContextMenu->menu();
d->m_folderMenu = mfolder->menu(); d->m_folderMenu = mfolderContextMenu->menu();
d->m_fileMenu = mfilec->menu(); d->m_fileMenu = mfileContextMenu->menu();
Core::ActionContainer *mfile = Core::ActionContainer *mfile =
am->actionContainer(Core::Constants::M_FILE); am->actionContainer(Core::Constants::M_FILE);
@@ -397,26 +398,26 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
msessionContextMenu->appendGroup(Constants::G_SESSION_OTHER); msessionContextMenu->appendGroup(Constants::G_SESSION_OTHER);
msessionContextMenu->appendGroup(Constants::G_SESSION_CONFIG); msessionContextMenu->appendGroup(Constants::G_SESSION_CONFIG);
mproject->appendGroup(Constants::G_PROJECT_FIRST); mprojectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
mproject->appendGroup(Constants::G_PROJECT_BUILD); mprojectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
mproject->appendGroup(Constants::G_PROJECT_RUN); mprojectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
mproject->appendGroup(Constants::G_PROJECT_FILES); mprojectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
mproject->appendGroup(Constants::G_PROJECT_OTHER); mprojectContextMenu->appendGroup(Constants::G_PROJECT_OTHER);
mproject->appendGroup(Constants::G_PROJECT_CONFIG); mprojectContextMenu->appendGroup(Constants::G_PROJECT_CONFIG);
msubProject->appendGroup(Constants::G_PROJECT_FIRST); msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
msubProject->appendGroup(Constants::G_PROJECT_BUILD); msubProjectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
msubProject->appendGroup(Constants::G_PROJECT_FILES); msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
msubProject->appendGroup(Constants::G_PROJECT_OTHER); msubProjectContextMenu->appendGroup(Constants::G_PROJECT_OTHER);
msubProject->appendGroup(Constants::G_PROJECT_CONFIG); msubProjectContextMenu->appendGroup(Constants::G_PROJECT_CONFIG);
mfolder->appendGroup(Constants::G_FOLDER_FILES); mfolderContextMenu->appendGroup(Constants::G_FOLDER_FILES);
mfolder->appendGroup(Constants::G_FOLDER_OTHER); mfolderContextMenu->appendGroup(Constants::G_FOLDER_OTHER);
mfolder->appendGroup(Constants::G_FOLDER_CONFIG); mfolderContextMenu->appendGroup(Constants::G_FOLDER_CONFIG);
mfilec->appendGroup(Constants::G_FILE_OPEN); mfileContextMenu->appendGroup(Constants::G_FILE_OPEN);
mfilec->appendGroup(Constants::G_FILE_OTHER); mfileContextMenu->appendGroup(Constants::G_FILE_OTHER);
mfilec->appendGroup(Constants::G_FILE_CONFIG); mfileContextMenu->appendGroup(Constants::G_FILE_CONFIG);
// "open with" submenu // "open with" submenu
Core::ActionContainer * const openWith = Core::ActionContainer * const openWith =
@@ -442,17 +443,17 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
sep = new QAction(this); sep = new QAction(this);
sep->setSeparator(true); sep->setSeparator(true);
cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Files.Sep"), globalcontext); cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Files.Sep"), projecTreeContext);
msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES); msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);
mproject->addAction(cmd, Constants::G_PROJECT_FILES); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
msubProject->addAction(cmd, Constants::G_PROJECT_FILES); msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
sep = new QAction(this); sep = new QAction(this);
sep->setSeparator(true); sep->setSeparator(true);
cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Config.Sep"), globalcontext); cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Config.Sep"), projecTreeContext);
msessionContextMenu->addAction(cmd, Constants::G_SESSION_CONFIG); msessionContextMenu->addAction(cmd, Constants::G_SESSION_CONFIG);
mproject->addAction(cmd, Constants::G_PROJECT_CONFIG); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_CONFIG);
msubProject->addAction(cmd, Constants::G_PROJECT_CONFIG); msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_CONFIG);
sep = new QAction(this); sep = new QAction(this);
sep->setSeparator(true); sep->setSeparator(true);
@@ -464,14 +465,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Other.Sep"), globalcontext); cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Other.Sep"), globalcontext);
mbuild->addAction(cmd, Constants::G_BUILD_OTHER); mbuild->addAction(cmd, Constants::G_BUILD_OTHER);
msessionContextMenu->addAction(cmd, Constants::G_SESSION_OTHER); msessionContextMenu->addAction(cmd, Constants::G_SESSION_OTHER);
mproject->addAction(cmd, Constants::G_PROJECT_OTHER); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_OTHER);
msubProject->addAction(cmd, Constants::G_PROJECT_OTHER); msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_OTHER);
sep = new QAction(this); sep = new QAction(this);
sep->setSeparator(true); sep->setSeparator(true);
cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Run.Sep"), globalcontext); cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Run.Sep"), globalcontext);
mbuild->addAction(cmd, Constants::G_BUILD_RUN); mbuild->addAction(cmd, Constants::G_BUILD_RUN);
mproject->addAction(cmd, Constants::G_PROJECT_RUN); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
sep = new QAction(this); sep = new QAction(this);
sep->setSeparator(true); sep->setSeparator(true);
@@ -504,23 +505,23 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// Default open action // Default open action
d->m_openFileAction = new QAction(tr("Open File"), this); d->m_openFileAction = new QAction(tr("Open File"), this);
cmd = am->registerAction(d->m_openFileAction, ProjectExplorer::Constants::OPENFILE, cmd = am->registerAction(d->m_openFileAction, ProjectExplorer::Constants::OPENFILE,
globalcontext); projecTreeContext);
mfilec->addAction(cmd, Constants::G_FILE_OPEN); mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
d->m_showInGraphicalShell = new QAction(FolderNavigationWidget::msgGraphicalShellAction(), this); d->m_showInGraphicalShell = new QAction(FolderNavigationWidget::msgGraphicalShellAction(), this);
cmd = am->registerAction(d->m_showInGraphicalShell, ProjectExplorer::Constants::SHOWINGRAPHICALSHELL, cmd = am->registerAction(d->m_showInGraphicalShell, ProjectExplorer::Constants::SHOWINGRAPHICALSHELL,
globalcontext); projecTreeContext);
mfilec->addAction(cmd, Constants::G_FILE_OPEN); mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
mfolder->addAction(cmd, Constants::G_FOLDER_FILES); mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
d->m_openTerminalHere = new QAction(FolderNavigationWidget::msgTerminalAction(), this); d->m_openTerminalHere = new QAction(FolderNavigationWidget::msgTerminalAction(), this);
cmd = am->registerAction(d->m_openTerminalHere, ProjectExplorer::Constants::OPENTERMIANLHERE, cmd = am->registerAction(d->m_openTerminalHere, ProjectExplorer::Constants::OPENTERMIANLHERE,
globalcontext); projecTreeContext);
mfilec->addAction(cmd, Constants::G_FILE_OPEN); mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
mfolder->addAction(cmd, Constants::G_FOLDER_FILES); mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
// Open With menu // Open With menu
mfilec->addMenu(openWith, ProjectExplorer::Constants::G_FILE_OPEN); mfileContextMenu->addMenu(openWith, ProjectExplorer::Constants::G_FILE_OPEN);
// recent projects menu // recent projects menu
Core::ActionContainer *mrecent = Core::ActionContainer *mrecent =
@@ -530,6 +531,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(mfile->menu(), SIGNAL(aboutToShow()), connect(mfile->menu(), SIGNAL(aboutToShow()),
this, SLOT(updateRecentProjectMenu())); this, SLOT(updateRecentProjectMenu()));
// XXX same action?
// unload action // unload action
d->m_unloadAction = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""), d->m_unloadAction = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""),
Utils::ParameterAction::EnabledWithParameter, this); Utils::ParameterAction::EnabledWithParameter, this);
@@ -621,34 +623,34 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// build action (context menu) // build action (context menu)
d->m_buildActionContextMenu = new Utils::ParameterAction(tr("Build Project"), tr("Build Project \"%1\""), d->m_buildActionContextMenu = new Utils::ParameterAction(tr("Build Project"), tr("Build Project \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this); Utils::ParameterAction::AlwaysEnabled, this);
cmd = am->registerAction(d->m_buildActionContextMenu, Constants::BUILDCM, globalcontext); cmd = am->registerAction(d->m_buildActionContextMenu, Constants::BUILDCM, projecTreeContext);
cmd->setAttribute(Core::Command::CA_UpdateText); cmd->setAttribute(Core::Command::CA_UpdateText);
cmd->setDefaultText(d->m_buildActionContextMenu->text()); cmd->setDefaultText(d->m_buildActionContextMenu->text());
mproject->addAction(cmd, Constants::G_PROJECT_BUILD); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
// rebuild action (context menu) // rebuild action (context menu)
d->m_rebuildActionContextMenu = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""), d->m_rebuildActionContextMenu = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this); Utils::ParameterAction::AlwaysEnabled, this);
cmd = am->registerAction(d->m_rebuildActionContextMenu, Constants::REBUILDCM, globalcontext); cmd = am->registerAction(d->m_rebuildActionContextMenu, Constants::REBUILDCM, projecTreeContext);
cmd->setAttribute(Core::Command::CA_UpdateText); cmd->setAttribute(Core::Command::CA_UpdateText);
cmd->setDefaultText(d->m_rebuildActionContextMenu->text()); cmd->setDefaultText(d->m_rebuildActionContextMenu->text());
mproject->addAction(cmd, Constants::G_PROJECT_BUILD); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
// deploy action (context menu) // deploy action (context menu)
d->m_deployActionContextMenu = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""), d->m_deployActionContextMenu = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this); Utils::ParameterAction::AlwaysEnabled, this);
cmd = am->registerAction(d->m_deployActionContextMenu, Constants::DEPLOYCM, globalcontext); cmd = am->registerAction(d->m_deployActionContextMenu, Constants::DEPLOYCM, projecTreeContext);
cmd->setAttribute(Core::Command::CA_UpdateText); cmd->setAttribute(Core::Command::CA_UpdateText);
cmd->setDefaultText(d->m_deployActionContextMenu->text()); cmd->setDefaultText(d->m_deployActionContextMenu->text());
mproject->addAction(cmd, Constants::G_PROJECT_BUILD); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
// clean action (context menu) // clean action (context menu)
d->m_cleanActionContextMenu = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""), d->m_cleanActionContextMenu = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this); Utils::ParameterAction::AlwaysEnabled, this);
cmd = am->registerAction(d->m_cleanActionContextMenu, Constants::CLEANCM, globalcontext); cmd = am->registerAction(d->m_cleanActionContextMenu, Constants::CLEANCM, projecTreeContext);
cmd->setAttribute(Core::Command::CA_UpdateText); cmd->setAttribute(Core::Command::CA_UpdateText);
cmd->setDefaultText(d->m_cleanActionContextMenu->text()); cmd->setDefaultText(d->m_cleanActionContextMenu->text());
mproject->addAction(cmd, Constants::G_PROJECT_BUILD); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
// build without dependencies action // build without dependencies action
d->m_buildProjectOnlyAction = new QAction(tr("Build Without Dependencies"), this); d->m_buildProjectOnlyAction = new QAction(tr("Build Without Dependencies"), this);
@@ -679,8 +681,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
modeManager->addAction(cmd, Constants::P_ACTION_RUN); modeManager->addAction(cmd, Constants::P_ACTION_RUN);
d->m_runActionContextMenu = new QAction(runIcon, tr("Run"), this); d->m_runActionContextMenu = new QAction(runIcon, tr("Run"), this);
cmd = am->registerAction(d->m_runActionContextMenu, Constants::RUNCONTEXTMENU, globalcontext); cmd = am->registerAction(d->m_runActionContextMenu, Constants::RUNCONTEXTMENU, projecTreeContext);
mproject->addAction(cmd, Constants::G_PROJECT_RUN); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
// cancel build action // cancel build action
d->m_cancelBuildAction = new QAction(tr("Cancel Build"), this); d->m_cancelBuildAction = new QAction(tr("Cancel Build"), this);
@@ -702,52 +704,52 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// add new file action // add new file action
d->m_addNewFileAction = new QAction(tr("Add New..."), this); d->m_addNewFileAction = new QAction(tr("Add New..."), this);
cmd = am->registerAction(d->m_addNewFileAction, ProjectExplorer::Constants::ADDNEWFILE, cmd = am->registerAction(d->m_addNewFileAction, ProjectExplorer::Constants::ADDNEWFILE,
globalcontext); projecTreeContext);
mproject->addAction(cmd, Constants::G_PROJECT_FILES); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
msubProject->addAction(cmd, Constants::G_PROJECT_FILES); msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
mfolder->addAction(cmd, Constants::G_FOLDER_FILES); mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
// add existing file action // add existing file action
d->m_addExistingFilesAction = new QAction(tr("Add Existing Files..."), this); d->m_addExistingFilesAction = new QAction(tr("Add Existing Files..."), this);
cmd = am->registerAction(d->m_addExistingFilesAction, ProjectExplorer::Constants::ADDEXISTINGFILES, cmd = am->registerAction(d->m_addExistingFilesAction, ProjectExplorer::Constants::ADDEXISTINGFILES,
globalcontext); projecTreeContext);
mproject->addAction(cmd, Constants::G_PROJECT_FILES); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
msubProject->addAction(cmd, Constants::G_PROJECT_FILES); msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
mfolder->addAction(cmd, Constants::G_FOLDER_FILES); mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
// new subproject action // new subproject action
d->m_addNewSubprojectAction = new QAction(tr("New Subproject..."), this); d->m_addNewSubprojectAction = new QAction(tr("New Subproject..."), this);
cmd = am->registerAction(d->m_addNewSubprojectAction, ProjectExplorer::Constants::ADDNEWSUBPROJECT, cmd = am->registerAction(d->m_addNewSubprojectAction, ProjectExplorer::Constants::ADDNEWSUBPROJECT,
globalcontext); projecTreeContext);
mproject->addAction(cmd, Constants::G_PROJECT_FILES); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
msubProject->addAction(cmd, Constants::G_PROJECT_FILES); msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
// unload project again, in right position // unload project again, in right position
mproject->addAction(am->command(Constants::UNLOAD), Constants::G_PROJECT_FILES); mprojectContextMenu->addAction(am->command(Constants::UNLOAD), Constants::G_PROJECT_FILES);
// remove file action // remove file action
d->m_removeFileAction = new QAction(tr("Remove File..."), this); d->m_removeFileAction = new QAction(tr("Remove File..."), this);
cmd = am->registerAction(d->m_removeFileAction, ProjectExplorer::Constants::REMOVEFILE, cmd = am->registerAction(d->m_removeFileAction, ProjectExplorer::Constants::REMOVEFILE,
globalcontext); projecTreeContext);
mfilec->addAction(cmd, Constants::G_FILE_OTHER); mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
//: Remove project from parent profile (Project explorer view); will not physically delete any files. //: Remove project from parent profile (Project explorer view); will not physically delete any files.
d->m_removeProjectAction = new QAction(tr("Remove Project..."), this); d->m_removeProjectAction = new QAction(tr("Remove Project..."), this);
cmd = am->registerAction(d->m_removeProjectAction, ProjectExplorer::Constants::REMOVEPROJECT, cmd = am->registerAction(d->m_removeProjectAction, ProjectExplorer::Constants::REMOVEPROJECT,
globalcontext); projecTreeContext);
msubProject->addAction(cmd, Constants::G_PROJECT_FILES); msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
// delete file action // delete file action
d->m_deleteFileAction = new QAction(tr("Delete File..."), this); d->m_deleteFileAction = new QAction(tr("Delete File..."), this);
cmd = am->registerAction(d->m_deleteFileAction, ProjectExplorer::Constants::DELETEFILE, cmd = am->registerAction(d->m_deleteFileAction, ProjectExplorer::Constants::DELETEFILE,
globalcontext); projecTreeContext);
mfilec->addAction(cmd, Constants::G_FILE_OTHER); mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
// renamefile action // renamefile action
d->m_renameFileAction = new QAction(tr("Rename"), this); d->m_renameFileAction = new QAction(tr("Rename"), this);
cmd = am->registerAction(d->m_renameFileAction, ProjectExplorer::Constants::RENAMEFILE, cmd = am->registerAction(d->m_renameFileAction, ProjectExplorer::Constants::RENAMEFILE,
globalcontext); projecTreeContext);
mfilec->addAction(cmd, Constants::G_FILE_OTHER); mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
// Not yet used by anyone, so hide for now // Not yet used by anyone, so hide for now
// mfolder->addAction(cmd, Constants::G_FOLDER_FILES); // mfolder->addAction(cmd, Constants::G_FOLDER_FILES);
// msubProject->addAction(cmd, Constants::G_FOLDER_FILES); // msubProject->addAction(cmd, Constants::G_FOLDER_FILES);
@@ -756,8 +758,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// set startup project action // set startup project action
d->m_setStartupProjectAction = new QAction(tr("Set as Startup Project"), this); d->m_setStartupProjectAction = new QAction(tr("Set as Startup Project"), this);
cmd = am->registerAction(d->m_setStartupProjectAction, ProjectExplorer::Constants::SETSTARTUP, cmd = am->registerAction(d->m_setStartupProjectAction, ProjectExplorer::Constants::SETSTARTUP,
globalcontext); projecTreeContext);
mproject->addAction(cmd, Constants::G_PROJECT_FIRST); mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FIRST);
// target selector // target selector
d->m_projectSelectorAction = new QAction(this); d->m_projectSelectorAction = new QAction(this);
@@ -1315,7 +1317,7 @@ void ProjectExplorerPlugin::showContextMenu(const QPoint &globalPos, Node *node)
contextMenu = d->m_sessionContextMenu; contextMenu = d->m_sessionContextMenu;
} }
updateContextMenuActions(node); updateContextMenuActions();
if (contextMenu && contextMenu->actions().count() > 0) { if (contextMenu && contextMenu->actions().count() > 0) {
contextMenu->popup(globalPos); contextMenu->popup(globalPos);
} }
@@ -1425,6 +1427,7 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
if (debug) if (debug)
qDebug() << "ProjectExplorer - currentNodeChanged(" << (node ? node->path() : "0") << ", " << (project ? project->displayName() : "0") << ")"; qDebug() << "ProjectExplorer - currentNodeChanged(" << (node ? node->path() : "0") << ", " << (project ? project->displayName() : "0") << ")";
emit currentNodeChanged(d->m_currentNode, project); emit currentNodeChanged(d->m_currentNode, project);
updateContextMenuActions();
} }
if (projectChanged) { if (projectChanged) {
if (debug) if (debug)
@@ -2027,21 +2030,22 @@ void ProjectExplorerPlugin::invalidateProject(Project *project)
updateActions(); updateActions();
} }
void ProjectExplorerPlugin::updateContextMenuActions(Node *node) void ProjectExplorerPlugin::updateContextMenuActions()
{ {
d->m_addExistingFilesAction->setEnabled(false); d->m_addExistingFilesAction->setEnabled(false);
d->m_addNewFileAction->setEnabled(false); d->m_addNewFileAction->setEnabled(false);
d->m_addNewSubprojectAction->setEnabled(false); d->m_addNewSubprojectAction->setEnabled(false);
d->m_removeFileAction->setEnabled(false); d->m_removeFileAction->setEnabled(false);
d->m_deleteFileAction->setEnabled(false); d->m_deleteFileAction->setEnabled(false);
d->m_renameFileAction->setEnabled(false);
d->m_addExistingFilesAction->setVisible(true); d->m_addExistingFilesAction->setVisible(true);
d->m_removeFileAction->setVisible(true); d->m_removeFileAction->setVisible(true);
d->m_deleteFileAction->setVisible(true); d->m_deleteFileAction->setVisible(true);
if (node->projectNode()) { if (d->m_currentNode && d->m_currentNode->projectNode()) {
QList<ProjectNode::ProjectAction> actions = QList<ProjectNode::ProjectAction> actions =
d->m_currentNode->projectNode()->supportedActions(node); d->m_currentNode->projectNode()->supportedActions(d->m_currentNode);
if (qobject_cast<FolderNode*>(d->m_currentNode)) { if (qobject_cast<FolderNode*>(d->m_currentNode)) {
d->m_addNewFileAction->setEnabled(actions.contains(ProjectNode::AddNewFile)); d->m_addNewFileAction->setEnabled(actions.contains(ProjectNode::AddNewFile));

View File

@@ -222,7 +222,7 @@ private:
QString directoryFor(Node *node); QString directoryFor(Node *node);
void deploy(QList<Project *>); void deploy(QList<Project *>);
int queue(QList<Project *>, QStringList stepIds); int queue(QList<Project *>, QStringList stepIds);
void updateContextMenuActions(Node *node); void updateContextMenuActions();
bool parseArguments(const QStringList &arguments, QString *error); bool parseArguments(const QStringList &arguments, QString *error);
void runProjectImpl(Project *pro, QString mode); void runProjectImpl(Project *pro, QString mode);
void executeRunConfiguration(RunConfiguration *, const QString &mode); void executeRunConfiguration(RunConfiguration *, const QString &mode);

View File

@@ -102,6 +102,7 @@ const int P_ACTION_BUILDSESSION = 80;
// context // context
const char * const C_PROJECTEXPLORER = "Project Explorer"; const char * const C_PROJECTEXPLORER = "Project Explorer";
const char * const C_PROJECT_TREE = "ProjectExplorer.ProjectTreeContext";
// languages // languages
const char * const LANG_CXX = "CXX"; const char * const LANG_CXX = "CXX";

View File

@@ -39,6 +39,8 @@
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icontext.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/navigationtreeview.h> #include <utils/navigationtreeview.h>
@@ -69,7 +71,18 @@ public:
setEditTriggers(QAbstractItemView::EditKeyPressed); setEditTriggers(QAbstractItemView::EditKeyPressed);
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
// setExpandsOnDoubleClick(false); // setExpandsOnDoubleClick(false);
Core::Context context(Constants::C_PROJECT_TREE);
m_context = new Core::BaseContext(this, context);
Core::ICore::instance()->addContextObject(m_context);
} }
~ProjectTreeView()
{
Core::ICore::instance()->removeContextObject(m_context);
delete m_context;
}
private:
Core::BaseContext *m_context;
}; };
/*! /*!