Commit a4b47282 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

VCS: Rework disabling of ambiguous actions



Task-number: QTCREATORBUG-13364
Change-Id: Ib9dc98964983f1a2808a89d90969089a09d2b55e
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 17c92cde
......@@ -162,8 +162,10 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
Q_UNUSED(arguments);
Q_UNUSED(errorMessage);
Context context(Constants::BAZAAR_CONTEXT);
m_client = new BazaarClient(&m_bazaarSettings);
initializeVcs(new BazaarControl(m_client));
initializeVcs(new BazaarControl(m_client), context);
addAutoReleasedObject(new OptionsPage);
m_bazaarSettings.readSettings(ICore::settings());
......@@ -193,7 +195,7 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
m_commandLocator = new CommandLocator("Bazaar", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
createMenu();
createMenu(context);
createSubmitEditorActions();
......@@ -226,10 +228,8 @@ void BazaarPlugin::setSettings(const BazaarSettings &settings)
}
}
void BazaarPlugin::createMenu()
void BazaarPlugin::createMenu(const Context &context)
{
Context context(Core::Constants::C_GLOBAL);
// Create menu item for Bazaar
m_bazaarContainer = ActionManager::createMenu("Bazaar.BazaarMenu");
QMenu *menu = m_bazaarContainer->menu();
......
......@@ -109,7 +109,7 @@ protected:
private:
// Functions
void createMenu();
void createMenu(const Core::Context &context);
void createSubmitEditorActions();
void createFileActions(const Core::Context &context);
void createDirectoryActions(const Core::Context &context);
......
......@@ -36,6 +36,7 @@ namespace Constants {
const char BAZAAR[] = "bazaar";
const char BAZAARREPO[] = ".bzr";
const char BAZAARDEFAULT[] = "bzr";
const char BAZAAR_CONTEXT[] = "Bazaar Context";
// Changeset identifiers
const char CHANGESET_ID[] = "^("
......
......@@ -111,6 +111,7 @@ using namespace Utils;
namespace ClearCase {
namespace Internal {
static const char CLEARCASE_CONTEXT[] = "ClearCase Context";
static const char CMD_ID_CLEARCASE_MENU[] = "ClearCase.Menu";
static const char CMD_ID_CHECKOUT[] = "ClearCase.CheckOut";
static const char CMD_ID_CHECKIN[] = "ClearCase.CheckInCurrent";
......@@ -437,7 +438,9 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
using namespace Constants;
using namespace Core::Constants;
initializeVcs(new ClearCaseControl(this));
Context context(CLEARCASE_CONTEXT);
initializeVcs(new ClearCaseControl(this), context);
m_clearcasePluginInstance = this;
connect(ICore::instance(), SIGNAL(coreAboutToClose()), this, SLOT(closing()));
......@@ -478,12 +481,11 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
clearcaseMenu->menu()->setTitle(tr("C&learCase"));
toolsContainer->addMenu(clearcaseMenu);
m_menuAction = clearcaseMenu->menu()->menuAction();
Context globalcontext(C_GLOBAL);
Command *command;
m_checkOutAction = new ParameterAction(tr("Check Out..."), tr("Check &Out \"%1\"..."), ParameterAction::AlwaysEnabled, this);
command = ActionManager::registerAction(m_checkOutAction, CMD_ID_CHECKOUT,
globalcontext);
context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+L,Meta+O") : tr("Alt+L,Alt+O")));
connect(m_checkOutAction, SIGNAL(triggered()), this, SLOT(checkOutCurrentFile()));
......@@ -491,7 +493,7 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
m_commandLocator->appendCommand(command);
m_checkInCurrentAction = new ParameterAction(tr("Check &In..."), tr("Check &In \"%1\"..."), ParameterAction::AlwaysEnabled, this);
command = ActionManager::registerAction(m_checkInCurrentAction, CMD_ID_CHECKIN, globalcontext);
command = ActionManager::registerAction(m_checkInCurrentAction, CMD_ID_CHECKIN, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+L,Meta+I") : tr("Alt+L,Alt+I")));
connect(m_checkInCurrentAction, SIGNAL(triggered()), this, SLOT(startCheckInCurrentFile()));
......@@ -499,7 +501,7 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
m_commandLocator->appendCommand(command);
m_undoCheckOutAction = new ParameterAction(tr("Undo Check Out"), tr("&Undo Check Out \"%1\""), ParameterAction::AlwaysEnabled, this);
command = ActionManager::registerAction(m_undoCheckOutAction, CMD_ID_UNDOCHECKOUT, globalcontext);
command = ActionManager::registerAction(m_undoCheckOutAction, CMD_ID_UNDOCHECKOUT, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+L,Meta+U") : tr("Alt+L,Alt+U")));
connect(m_undoCheckOutAction, SIGNAL(triggered()), this, SLOT(undoCheckOutCurrent()));
......@@ -507,18 +509,18 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
m_commandLocator->appendCommand(command);
m_undoHijackAction = new ParameterAction(tr("Undo Hijack"), tr("Undo Hi&jack \"%1\""), ParameterAction::AlwaysEnabled, this);
command = ActionManager::registerAction(m_undoHijackAction, CMD_ID_UNDOHIJACK, globalcontext);
command = ActionManager::registerAction(m_undoHijackAction, CMD_ID_UNDOHIJACK, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+L,Meta+R") : tr("Alt+L,Alt+R")));
connect(m_undoHijackAction, SIGNAL(triggered()), this, SLOT(undoHijackCurrent()));
clearcaseMenu->addAction(command);
m_commandLocator->appendCommand(command);
clearcaseMenu->addSeparator(globalcontext);
clearcaseMenu->addSeparator(context);
m_diffCurrentAction = new ParameterAction(tr("Diff Current File"), tr("&Diff \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_diffCurrentAction,
CMD_ID_DIFF_CURRENT, globalcontext);
CMD_ID_DIFF_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+L,Meta+D") : tr("Alt+L,Alt+D")));
connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
......@@ -527,7 +529,7 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
m_historyCurrentAction = new ParameterAction(tr("History Current File"), tr("&History \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_historyCurrentAction,
CMD_ID_HISTORY_CURRENT, globalcontext);
CMD_ID_HISTORY_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+L,Meta+H") : tr("Alt+L,Alt+H")));
connect(m_historyCurrentAction, SIGNAL(triggered()), this,
......@@ -537,7 +539,7 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
m_annotateCurrentAction = new ParameterAction(tr("Annotate Current File"), tr("&Annotate \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_annotateCurrentAction,
CMD_ID_ANNOTATE, globalcontext);
CMD_ID_ANNOTATE, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+L,Meta+A") : tr("Alt+L,Alt+A")));
connect(m_annotateCurrentAction, SIGNAL(triggered()), this,
......@@ -546,52 +548,52 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
m_commandLocator->appendCommand(command);
m_addFileAction = new ParameterAction(tr("Add File..."), tr("Add File \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_addFileAction, CMD_ID_ADD_FILE, globalcontext);
command = ActionManager::registerAction(m_addFileAction, CMD_ID_ADD_FILE, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_addFileAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
clearcaseMenu->addAction(command);
clearcaseMenu->addSeparator(globalcontext);
clearcaseMenu->addSeparator(context);
m_diffActivityAction = new QAction(tr("Diff A&ctivity..."), this);
m_diffActivityAction->setEnabled(false);
command = ActionManager::registerAction(m_diffActivityAction, CMD_ID_DIFF_ACTIVITY, globalcontext);
command = ActionManager::registerAction(m_diffActivityAction, CMD_ID_DIFF_ACTIVITY, context);
connect(m_diffActivityAction, SIGNAL(triggered()), this, SLOT(diffActivity()));
clearcaseMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_checkInActivityAction = new ParameterAction(tr("Ch&eck In Activity"), tr("Chec&k In Activity \"%1\"..."), ParameterAction::EnabledWithParameter, this);
m_checkInActivityAction->setEnabled(false);
command = ActionManager::registerAction(m_checkInActivityAction, CMD_ID_CHECKIN_ACTIVITY, globalcontext);
command = ActionManager::registerAction(m_checkInActivityAction, CMD_ID_CHECKIN_ACTIVITY, context);
connect(m_checkInActivityAction, SIGNAL(triggered()), this, SLOT(startCheckInActivity()));
command->setAttribute(Command::CA_UpdateText);
clearcaseMenu->addAction(command);
m_commandLocator->appendCommand(command);
clearcaseMenu->addSeparator(globalcontext);
clearcaseMenu->addSeparator(context);
m_updateIndexAction = new QAction(tr("Update Index"), this);
command = ActionManager::registerAction(m_updateIndexAction, CMD_ID_UPDATEINDEX, globalcontext);
command = ActionManager::registerAction(m_updateIndexAction, CMD_ID_UPDATEINDEX, context);
connect(m_updateIndexAction, SIGNAL(triggered()), this, SLOT(updateIndex()));
clearcaseMenu->addAction(command);
m_updateViewAction = new ParameterAction(tr("Update View"), tr("U&pdate View \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_updateViewAction, CMD_ID_UPDATE_VIEW, globalcontext);
command = ActionManager::registerAction(m_updateViewAction, CMD_ID_UPDATE_VIEW, context);
connect(m_updateViewAction, SIGNAL(triggered()), this, SLOT(updateView()));
command->setAttribute(Command::CA_UpdateText);
clearcaseMenu->addAction(command);
clearcaseMenu->addSeparator(globalcontext);
clearcaseMenu->addSeparator(context);
m_checkInAllAction = new QAction(tr("Check In All &Files..."), this);
command = ActionManager::registerAction(m_checkInAllAction, CMD_ID_CHECKIN_ALL, globalcontext);
command = ActionManager::registerAction(m_checkInAllAction, CMD_ID_CHECKIN_ALL, context);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+L,Meta+F") : tr("Alt+L,Alt+F")));
connect(m_checkInAllAction, SIGNAL(triggered()), this, SLOT(startCheckInAll()));
clearcaseMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_statusAction = new QAction(tr("View &Status"), this);
command = ActionManager::registerAction(m_statusAction, CMD_ID_STATUS, globalcontext);
command = ActionManager::registerAction(m_statusAction, CMD_ID_STATUS, context);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+L,Meta+S") : tr("Alt+L,Alt+S")));
connect(m_statusAction, SIGNAL(triggered()), this, SLOT(viewStatus()));
clearcaseMenu->addAction(command);
......
......@@ -307,18 +307,6 @@ Command *ActionContainerPrivate::addSeparator(const Context &context, Id group,
return cmd;
}
void ActionContainerPrivate::setEnabled(bool enabled)
{
foreach (const Group &group, m_groups) {
foreach (QObject *item, group.items) {
if (Command *command = qobject_cast<Command *>(item))
command->action()->setEnabled(enabled);
else if (ActionContainer *container = qobject_cast<ActionContainer *>(item))
container->setEnabled(enabled);
}
}
}
void ActionContainerPrivate::clear()
{
QMutableListIterator<Group> it(m_groups);
......
......@@ -72,7 +72,6 @@ public:
virtual void addMenu(ActionContainer *menu, Id group = Id()) = 0;
virtual void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id()) = 0;
virtual Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = 0) = 0;
virtual void setEnabled(bool enabled) = 0;
// This clears this menu and submenus from all actions and submenus.
// It does not destroy the submenus and commands, just removes them from their parents.
......
......@@ -64,7 +64,6 @@ public:
void addMenu(ActionContainer *menu, Id group = Id());
void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id());
Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = 0);
void setEnabled(bool enabled);
virtual void clear();
Id id() const;
......
......@@ -95,6 +95,7 @@ static inline QString msgLogParsingFailed()
return CvsPlugin::tr("Parsing of the log output failed");
}
const char CVS_CONTEXT[] = "CVS Context";
const char CMD_ID_CVS_MENU[] = "CVS.Menu";
const char CMD_ID_ADD[] = "CVS.Add";
const char CMD_ID_DELETE_FILE[] = "CVS.Delete";
......@@ -228,7 +229,9 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
using namespace Constants;
using namespace Core::Constants;
initializeVcs(new CvsControl(this));
Context context(CVS_CONTEXT);
initializeVcs(new CvsControl(this), context);
m_cvsPluginInstance = this;
......@@ -271,13 +274,11 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
toolsContainer->addMenu(cvsMenu);
m_menuAction = cvsMenu->menu()->menuAction();
Context globalcontext(C_GLOBAL);
Command *command;
m_diffCurrentAction = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_diffCurrentAction,
CMD_ID_DIFF_CURRENT, globalcontext);
CMD_ID_DIFF_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+D") : tr("Alt+C,Alt+D")));
connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
......@@ -286,7 +287,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_filelogCurrentAction = new ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_filelogCurrentAction,
CMD_ID_FILELOG_CURRENT, globalcontext);
CMD_ID_FILELOG_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_filelogCurrentAction, SIGNAL(triggered()), this,
SLOT(filelogCurrentFile()));
......@@ -295,18 +296,18 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_annotateCurrentAction = new ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_annotateCurrentAction,
CMD_ID_ANNOTATE_CURRENT, globalcontext);
CMD_ID_ANNOTATE_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_annotateCurrentAction, SIGNAL(triggered()), this,
SLOT(annotateCurrentFile()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
cvsMenu->addSeparator(globalcontext);
cvsMenu->addSeparator(context);
m_addAction = new ParameterAction(tr("Add"), tr("Add \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_addAction, CMD_ID_ADD,
globalcontext);
context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+A") : tr("Alt+C,Alt+A")));
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
......@@ -315,7 +316,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_commitCurrentAction = new ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_commitCurrentAction,
CMD_ID_COMMIT_CURRENT, globalcontext);
CMD_ID_COMMIT_CURRENT, context);
command->setAttribute(Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+C") : tr("Alt+C,Alt+C")));
connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile()));
......@@ -324,7 +325,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_deleteAction = new ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
globalcontext);
context);
command->setAttribute(Command::CA_UpdateText);
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
cvsMenu->addAction(command);
......@@ -332,39 +333,39 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_revertAction = new ParameterAction(tr("Revert..."), tr("Revert \"%1\"..."), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_revertAction, CMD_ID_REVERT,
globalcontext);
context);
command->setAttribute(Command::CA_UpdateText);
connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
cvsMenu->addSeparator(globalcontext);
cvsMenu->addSeparator(context);
m_editCurrentAction = new ParameterAction(tr("Edit"), tr("Edit \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_editCurrentAction, CMD_ID_EDIT_FILE, globalcontext);
command = ActionManager::registerAction(m_editCurrentAction, CMD_ID_EDIT_FILE, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_editCurrentAction, SIGNAL(triggered()), this, SLOT(editCurrentFile()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_uneditCurrentAction = new ParameterAction(tr("Unedit"), tr("Unedit \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_uneditCurrentAction, CMD_ID_UNEDIT_FILE, globalcontext);
command = ActionManager::registerAction(m_uneditCurrentAction, CMD_ID_UNEDIT_FILE, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_uneditCurrentAction, SIGNAL(triggered()), this, SLOT(uneditCurrentFile()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_uneditRepositoryAction = new QAction(tr("Unedit Repository"), this);
command = ActionManager::registerAction(m_uneditRepositoryAction, CMD_ID_UNEDIT_REPOSITORY, globalcontext);
command = ActionManager::registerAction(m_uneditRepositoryAction, CMD_ID_UNEDIT_REPOSITORY, context);
connect(m_uneditRepositoryAction, SIGNAL(triggered()), this, SLOT(uneditCurrentRepository()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
cvsMenu->addSeparator(globalcontext);
cvsMenu->addSeparator(context);
m_diffProjectAction = new ParameterAction(tr("Diff Project"), tr("Diff Project \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT,
globalcontext);
context);
command->setAttribute(Command::CA_UpdateText);
connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject()));
cvsMenu->addAction(command);
......@@ -372,69 +373,69 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_statusProjectAction = new ParameterAction(tr("Project Status"), tr("Status of Project \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_statusProjectAction, CMD_ID_STATUS,
globalcontext);
context);
command->setAttribute(Command::CA_UpdateText);
connect(m_statusProjectAction, SIGNAL(triggered()), this, SLOT(projectStatus()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_logProjectAction = new ParameterAction(tr("Log Project"), tr("Log Project \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, globalcontext);
command = ActionManager::registerAction(m_logProjectAction, CMD_ID_PROJECTLOG, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_updateProjectAction = new ParameterAction(tr("Update Project"), tr("Update Project \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_updateProjectAction, CMD_ID_UPDATE, globalcontext);
command = ActionManager::registerAction(m_updateProjectAction, CMD_ID_UPDATE, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_commitProjectAction = new ParameterAction(tr("Commit Project"), tr("Commit Project \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_commitProjectAction, CMD_ID_PROJECTCOMMIT, globalcontext);
command = ActionManager::registerAction(m_commitProjectAction, CMD_ID_PROJECTCOMMIT, context);
command->setAttribute(Command::CA_UpdateText);
connect(m_commitProjectAction, SIGNAL(triggered()), this, SLOT(commitProject()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
cvsMenu->addSeparator(globalcontext);
cvsMenu->addSeparator(context);
m_diffRepositoryAction = new QAction(tr("Diff Repository"), this);
command = ActionManager::registerAction(m_diffRepositoryAction, CMD_ID_REPOSITORYDIFF, globalcontext);
command = ActionManager::registerAction(m_diffRepositoryAction, CMD_ID_REPOSITORYDIFF, context);
connect(m_diffRepositoryAction, SIGNAL(triggered()), this, SLOT(diffRepository()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_statusRepositoryAction = new QAction(tr("Repository Status"), this);
command = ActionManager::registerAction(m_statusRepositoryAction, CMD_ID_REPOSITORYSTATUS, globalcontext);
command = ActionManager::registerAction(m_statusRepositoryAction, CMD_ID_REPOSITORYSTATUS, context);
connect(m_statusRepositoryAction, SIGNAL(triggered()), this, SLOT(statusRepository()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_logRepositoryAction = new QAction(tr("Repository Log"), this);
command = ActionManager::registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, globalcontext);
command = ActionManager::registerAction(m_logRepositoryAction, CMD_ID_REPOSITORYLOG, context);
connect(m_logRepositoryAction, SIGNAL(triggered()), this, SLOT(logRepository()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_updateRepositoryAction = new QAction(tr("Update Repository"), this);
command = ActionManager::registerAction(m_updateRepositoryAction, CMD_ID_REPOSITORYUPDATE, globalcontext);
command = ActionManager::registerAction(m_updateRepositoryAction, CMD_ID_REPOSITORYUPDATE, context);
connect(m_updateRepositoryAction, SIGNAL(triggered()), this, SLOT(updateRepository()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_commitAllAction = new QAction(tr("Commit All Files"), this);
command = ActionManager::registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL,
globalcontext);
context);
connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
m_revertRepositoryAction = new QAction(tr("Revert Repository..."), this);
command = ActionManager::registerAction(m_revertRepositoryAction, CMD_ID_REVERT_ALL,
globalcontext);
context);
connect(m_revertRepositoryAction, SIGNAL(triggered()), this, SLOT(revertAll()));
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
......
......@@ -47,6 +47,7 @@ const char GIT_COMMIT_TEXT_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git
const char GIT_REBASE_EDITOR_ID[] = "Git Rebase Editor";
const char GIT_REBASE_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Rebase Editor");
const char GIT_CONTEXT[] = "Git Context";
const char GITSUBMITEDITOR_ID[] = "Git Submit Editor";
const char GITSUBMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Submit Editor");
const char SUBMIT_CURRENT[] = "Git.SubmitCurrentLog";
......
This diff is collapsed.
......@@ -199,7 +199,6 @@ private:
void updateVersionWarning();
Core::CommandLocator *m_commandLocator;
Core::ActionContainer *m_gitContainer;
QAction *m_submitCurrentAction;
QAction *m_diffSelectedFilesAction;
......
......@@ -37,6 +37,7 @@ namespace Constants {
enum { debug = 0 };
const char MERCURIALREPO[] = ".hg";
const char MERCURIALDEFAULT[] = "hg";
const char MERCURIAL_CONTEXT[] = "Mercurial Context";
// Changeset identifiers
const char CHANGESETID12[] = " ([a-f0-9]{12,12}) "; //match 12 hex chars and capture
......
......@@ -133,8 +133,10 @@ MercurialPlugin::~MercurialPlugin()
bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * /*errorMessage */)
{
Core::Context context(Constants::MERCURIAL_CONTEXT);
m_client = new MercurialClient(&mercurialSettings);
initializeVcs(new MercurialControl(m_client));
initializeVcs(new MercurialControl(m_client), context);
optionsPage = new OptionsPage();
addAutoReleasedObject(optionsPage);
......@@ -166,7 +168,7 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
m_commandLocator = new Core::CommandLocator("Mercurial", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
createMenu();
createMenu(context);
createSubmitEditorActions();
......@@ -186,10 +188,8 @@ void MercurialPlugin::setSettings(const MercurialSettings &settings)
}
}
void MercurialPlugin::createMenu()
void MercurialPlugin::createMenu(const Core::Context &context)
{
Core::Context context(Core::Constants::C_GLOBAL);
// Create menu item for Mercurial
m_mercurialContainer = Core::ActionManager::createMenu("Mercurial.MercurialMenu");
QMenu *menu = m_mercurialContainer->menu();
......@@ -659,13 +659,11 @@ void MercurialPlugin::createRepositoryManagementActions(const Core::Context &con
void MercurialPlugin::updateActions(VcsBasePlugin::ActionState as)
{
if (!enableMenuAction(as, m_menuAction)) {
m_mercurialContainer->setEnabled(false);
m_commandLocator->setEnabled(false);
return;
}
const QString filename = currentState().currentFileName();
const bool repoEnabled = currentState().hasTopLevel();
m_mercurialContainer->setEnabled(repoEnabled);
m_commandLocator->setEnabled(repoEnabled);
annotateFile->setParameter(filename);
......
......@@ -129,7 +129,7 @@ protected:
bool submitEditorAboutToClose();
private:
void createMenu();
void createMenu(const Core::Context &context);
void createSubmitEditorActions();
void createFileActions(const Core::Context &context);
void createDirectoryActions(const Core::Context &context);
......
......@@ -83,6 +83,7 @@ const char SUBMIT_CURRENT[] = "Perforce.SubmitCurrentLog";
const char DIFF_SELECTED[] = "Perforce.DiffSelectedFilesInLog";
const char SUBMIT_MIMETYPE[] = "text/vnd.qtcreator.p4.submit";
const char PERFORCE_CONTEXT[] = "Perforce Context";
const char PERFORCE_SUBMIT_EDITOR_ID[] = "Perforce.SubmitEditor";
const char PERFORCE_SUBMIT_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Perforce.SubmitEditor");
......@@ -182,7 +183,6 @@ PerforcePlugin *PerforcePlugin::m_instance = NULL;
PerforcePlugin::PerforcePlugin() :
m_commandLocator(0),
m_perforceContainer(0),
m_editAction(0),
m_addAction(0),
m_deleteAction(0),
......@@ -221,7 +221,9 @@ static const VcsBaseSubmitEditorParameters submitParameters = {
bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *errorMessage)
{
initializeVcs(new PerforceVersionControl(this));
Context context(PERFORCE_CONTEXT);
initializeVcs(new PerforceVersionControl(this), context);
if (!MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.perforce/Perforce.mimetypes.xml"), errorMessage))
return false;
......@@ -247,177 +249,176 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
m_perforceContainer = ActionManager::createMenu(CMD_ID_PERFORCE_MENU);
m_perforceContainer->menu()->setTitle(tr("&Perforce"));
mtools->addMenu(m_perforceContainer);
m_menuAction = m_perforceContainer->menu()->menuAction();
Core::ActionContainer *perforceContainer = ActionManager::createMenu(CMD_ID_PERFORCE_MENU);
perforceContainer->menu()->setTitle(tr("&Perforce"));
mtools->addMenu(perforceContainer);
m_menuAction = perforceContainer->menu()->menuAction();
Context globalcontext(Core::Constants::C_GLOBAL);
Context perforcesubmitcontext(PERFORCE_SUBMIT_EDITOR_ID);
Core::Command *command;
m_diffFileAction = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this);
command = ActionManager::registerAction(m_diffFileAction, CMD_ID_DIFF_CURRENT, globalcontext);
command = ActionManager::registerAction(m_diffFileAction, CMD_ID_DIFF_CURRENT, context);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDescription(tr("Diff Current File"));