Mercurial: Disable hidden menu entries

To avoid shortcut ambiguity

Task-number: QTCREATORBUG-13364
Change-Id: Ibce1701be72376845624856b5de097332aaaccae
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2014-11-09 10:15:46 +02:00
committed by Orgad Shaneh
parent 895e0d8439
commit a43f162d0a
5 changed files with 45 additions and 29 deletions

View File

@@ -191,22 +191,22 @@ void MercurialPlugin::createMenu()
Core::Context context(Core::Constants::C_GLOBAL);
// Create menu item for Mercurial
mercurialContainer = Core::ActionManager::createMenu("Mercurial.MercurialMenu");
QMenu *menu = mercurialContainer->menu();
m_mercurialContainer = Core::ActionManager::createMenu("Mercurial.MercurialMenu");
QMenu *menu = m_mercurialContainer->menu();
menu->setTitle(tr("Me&rcurial"));
createFileActions(context);
mercurialContainer->addSeparator(context);
m_mercurialContainer->addSeparator(context);
createDirectoryActions(context);
mercurialContainer->addSeparator(context);
m_mercurialContainer->addSeparator(context);
createRepositoryActions(context);
mercurialContainer->addSeparator(context);
m_mercurialContainer->addSeparator(context);
createRepositoryManagementActions(context);
// Request the Tools menu and add the Mercurial menu to it
Core::ActionContainer *toolsMenu = Core::ActionManager::actionContainer(Core::Id(Core::Constants::M_TOOLS));
toolsMenu->addMenu(mercurialContainer);
m_menuAction = mercurialContainer->menu()->menuAction();
toolsMenu->addMenu(m_mercurialContainer);
m_menuAction = m_mercurialContainer->menu()->menuAction();
}
void MercurialPlugin::createFileActions(const Core::Context &context)
@@ -217,7 +217,7 @@ void MercurialPlugin::createFileActions(const Core::Context &context)
command = Core::ActionManager::registerAction(annotateFile, Core::Id(Constants::ANNOTATE), context);
command->setAttribute(Core::Command::CA_UpdateText);
connect(annotateFile, SIGNAL(triggered()), this, SLOT(annotateCurrentFile()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
diffFile = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this);
@@ -225,7 +225,7 @@ void MercurialPlugin::createFileActions(const Core::Context &context)
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+D") : tr("Alt+G,Alt+D")));
connect(diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
logFile = new ParameterAction(tr("Log Current File"), tr("Log \"%1\""), ParameterAction::EnabledWithParameter, this);
@@ -233,7 +233,7 @@ void MercurialPlugin::createFileActions(const Core::Context &context)
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+L") : tr("Alt+G,Alt+L")));
connect(logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
statusFile = new ParameterAction(tr("Status Current File"), tr("Status \"%1\""), ParameterAction::EnabledWithParameter, this);
@@ -241,30 +241,30 @@ void MercurialPlugin::createFileActions(const Core::Context &context)
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+S") : tr("Alt+G,Alt+S")));
connect(statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
mercurialContainer->addSeparator(context);
m_mercurialContainer->addSeparator(context);
m_addAction = new ParameterAction(tr("Add"), tr("Add \"%1\""), ParameterAction::EnabledWithParameter, this);
command = Core::ActionManager::registerAction(m_addAction, Core::Id(Constants::ADD), context);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
m_deleteAction = new ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), ParameterAction::EnabledWithParameter, this);
command = Core::ActionManager::registerAction(m_deleteAction, Core::Id(Constants::DELETE), context);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(promptToDeleteCurrentFile()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
revertFile = new ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), ParameterAction::EnabledWithParameter, this);
command = Core::ActionManager::registerAction(revertFile, Core::Id(Constants::REVERT), context);
command->setAttribute(Core::Command::CA_UpdateText);
connect(revertFile, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
}
@@ -327,28 +327,28 @@ void MercurialPlugin::createDirectoryActions(const Core::Context &context)
m_repositoryActionList.append(action);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::DIFFMULTI), context);
connect(action, SIGNAL(triggered()), this, SLOT(diffRepository()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Log"), this);
m_repositoryActionList.append(action);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::LOGMULTI), context);
connect(action, SIGNAL(triggered()), this, SLOT(logRepository()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Revert..."), this);
m_repositoryActionList.append(action);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::REVERTMULTI), context);
connect(action, SIGNAL(triggered()), this, SLOT(revertMulti()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Status"), this);
m_repositoryActionList.append(action);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::STATUSMULTI), context);
connect(action, SIGNAL(triggered()), this, SLOT(statusMulti()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
}
@@ -391,42 +391,42 @@ void MercurialPlugin::createRepositoryActions(const Core::Context &context)
m_repositoryActionList.append(action);
Core::Command *command = Core::ActionManager::registerAction(action, Core::Id(Constants::PULL), context);
connect(action, SIGNAL(triggered()), this, SLOT(pull()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Push..."), this);
m_repositoryActionList.append(action);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::PUSH), context);
connect(action, SIGNAL(triggered()), this, SLOT(push()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Update..."), this);
m_repositoryActionList.append(action);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::UPDATE), context);
connect(action, SIGNAL(triggered()), this, SLOT(update()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Import..."), this);
m_repositoryActionList.append(action);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::IMPORT), context);
connect(action, SIGNAL(triggered()), this, SLOT(import()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Incoming..."), this);
m_repositoryActionList.append(action);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::INCOMING), context);
connect(action, SIGNAL(triggered()), this, SLOT(incoming()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Outgoing..."), this);
m_repositoryActionList.append(action);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::OUTGOING), context);
connect(action, SIGNAL(triggered()), this, SLOT(outgoing()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Commit..."), this);
@@ -434,13 +434,13 @@ void MercurialPlugin::createRepositoryActions(const Core::Context &context)
command = Core::ActionManager::registerAction(action, Core::Id(Constants::COMMIT), context);
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+C") : tr("Alt+G,Alt+C")));
connect(action, SIGNAL(triggered()), this, SLOT(commit()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
m_commandLocator->appendCommand(command);
m_createRepositoryAction = new QAction(tr("Create Repository..."), this);
command = Core::ActionManager::registerAction(m_createRepositoryAction, Core::Id(Constants::CREATE_REPOSITORY), context);
connect(m_createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
mercurialContainer->addAction(command);
m_mercurialContainer->addAction(command);
}
void MercurialPlugin::pull()
@@ -653,17 +653,19 @@ void MercurialPlugin::createRepositoryManagementActions(const Core::Context &con
// actionList.append(action);
// Core::Command *command = Core::ActionManager::registerAction(action, Constants::BRANCH, context);
// // connect(action, SIGNAL(triggered()), this, SLOT(branch()));
// mercurialContainer->addAction(command);
// m_mercurialContainer->addAction(command);
}
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);