Commit 3934347f authored by Eike Ziller's avatar Eike Ziller Committed by hjk
Browse files

ActionManager API cleanup.



d-pointer instead of inheritance
static methods

Change-Id: I7b2f0c8b05ad3951e1ff26a7d4e08e195d2dd258
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 7c7ccdc7
......@@ -170,13 +170,13 @@
\row
\o Add a menu or menu item.
\o You can extend existing menus or create new ones.
\o \l{Core::ActionManager}, \l{Core::Command}, \l{Core::ICore::actionManager()}
\o \l{Core::ActionManager}, \l{Core::Command}
\row
\o Add a configurable keyboard shortcut.
\o Registering shortcuts makes it possible for users to configure them in
the common shortcut settings dialog.
\o \l{Core::ActionManager}, \l{Core::Command}, \l{Core::ICore::actionManager()}
\o \l{Core::ActionManager}, \l{Core::Command}
\row
\o Add a mode.
......
......@@ -39,18 +39,17 @@ bool %PluginName%Plugin::initialize(const QStringList &arguments, QString *error
Q_UNUSED(arguments)
Q_UNUSED(errorString)
Core::ActionManager *am = Core::ICore::actionManager();
QAction *action = new QAction(tr("%PluginName% action"), this);
Core::Command *cmd = am->registerAction(action, Constants::ACTION_ID,
Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID,
Core::Context(Core::Constants::C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A")));
connect(action, SIGNAL(triggered()), this, SLOT(triggerAction()));
Core::ActionContainer *menu = am->createMenu(Constants::MENU_ID);
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID);
menu->menu()->setTitle(tr("%PluginName%"));
menu->addAction(cmd);
am->actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
return true;
}
......
......@@ -258,12 +258,11 @@ AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
void AnalyzerManagerPrivate::setupActions()
{
ActionManager *am = ICore::actionManager();
const Context globalcontext(C_GLOBAL);
Command *command = 0;
// Menus
m_menu = am->createMenu(M_DEBUG_ANALYZER);
m_menu = Core::ActionManager::createMenu(M_DEBUG_ANALYZER);
m_menu->menu()->setTitle(tr("&Analyze"));
m_menu->menu()->setEnabled(true);
......@@ -272,36 +271,36 @@ void AnalyzerManagerPrivate::setupActions()
m_menu->appendGroup(G_ANALYZER_REMOTE_TOOLS);
m_menu->appendGroup(G_ANALYZER_OPTIONS);
ActionContainer *menubar = am->actionContainer(MENU_BAR);
ActionContainer *mtools = am->actionContainer(M_TOOLS);
ActionContainer *menubar = Core::ActionManager::actionContainer(MENU_BAR);
ActionContainer *mtools = Core::ActionManager::actionContainer(M_TOOLS);
menubar->addMenu(mtools, m_menu);
m_startAction = new QAction(tr("Start"), m_menu);
m_startAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_START_ICON)));
command = am->registerAction(m_startAction, "Analyzer.Start", globalcontext);
command = Core::ActionManager::registerAction(m_startAction, "Analyzer.Start", globalcontext);
connect(m_startAction, SIGNAL(triggered()), this, SLOT(startTool()));
m_stopAction = new QAction(tr("Stop"), m_menu);
m_stopAction->setEnabled(false);
m_stopAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_STOP_ICON)));
command = am->registerAction(m_stopAction, "Analyzer.Stop", globalcontext);
command = Core::ActionManager::registerAction(m_stopAction, "Analyzer.Stop", globalcontext);
m_menu->addAction(command, G_ANALYZER_CONTROL);
QAction *separatorAction1 = new QAction(m_menu);
separatorAction1->setSeparator(true);
command = am->registerAction(separatorAction1,
command = Core::ActionManager::registerAction(separatorAction1,
"Menu.Action.Analyzer.Tools.Separator1", globalcontext);
m_menu->addAction(command, G_ANALYZER_TOOLS);
QAction *separatorAction2 = new QAction(m_menu);
separatorAction2->setSeparator(true);
command = am->registerAction(separatorAction2,
command = Core::ActionManager::registerAction(separatorAction2,
"Menu.Action.Analyzer.Tools.Separator2", globalcontext);
m_menu->addAction(command, G_ANALYZER_REMOTE_TOOLS);
QAction *separatorAction3 = new QAction(m_menu);
separatorAction3->setSeparator(true);
command = am->registerAction(separatorAction3,
command = Core::ActionManager::registerAction(separatorAction3,
"Menu.Action.Analyzer.Tools.Separator3", globalcontext);
m_menu->addAction(command, G_ANALYZER_OPTIONS);
}
......@@ -334,21 +333,20 @@ void AnalyzerManagerPrivate::delayedInit()
// Populate Windows->Views menu with standard actions.
Context analyzerContext(C_ANALYZEMODE);
ActionManager *am = ICore::actionManager();
ActionContainer *viewsMenu = am->actionContainer(Id(M_WINDOW_VIEWS));
Command *cmd = am->registerAction(m_mainWindow->menuSeparator1(),
ActionContainer *viewsMenu = Core::ActionManager::actionContainer(Id(M_WINDOW_VIEWS));
Command *cmd = Core::ActionManager::registerAction(m_mainWindow->menuSeparator1(),
Id("Analyzer.Views.Separator1"), analyzerContext);
cmd->setAttribute(Command::CA_Hide);
viewsMenu->addAction(cmd, G_DEFAULT_THREE);
cmd = am->registerAction(m_mainWindow->toggleLockedAction(),
cmd = Core::ActionManager::registerAction(m_mainWindow->toggleLockedAction(),
Id("Analyzer.Views.ToggleLocked"), analyzerContext);
cmd->setAttribute(Command::CA_Hide);
viewsMenu->addAction(cmd, G_DEFAULT_THREE);
cmd = am->registerAction(m_mainWindow->menuSeparator2(),
cmd = Core::ActionManager::registerAction(m_mainWindow->menuSeparator2(),
Id("Analyzer.Views.Separator2"), analyzerContext);
cmd->setAttribute(Command::CA_Hide);
viewsMenu->addAction(cmd, G_DEFAULT_THREE);
cmd = am->registerAction(m_mainWindow->resetLayoutAction(),
cmd = Core::ActionManager::registerAction(m_mainWindow->resetLayoutAction(),
Id("Analyzer.Views.ResetSimple"), analyzerContext);
cmd->setAttribute(Command::CA_Hide);
viewsMenu->addAction(cmd, G_DEFAULT_THREE);
......@@ -428,22 +426,20 @@ void AnalyzerManagerPrivate::activateDock(Qt::DockWidgetArea area, QDockWidget *
Context globalContext(C_GLOBAL);
ActionManager *am = ICore::actionManager();
QAction *toggleViewAction = dockWidget->toggleViewAction();
toggleViewAction->setText(dockWidget->windowTitle());
Command *cmd = am->registerAction(toggleViewAction,
Command *cmd = Core::ActionManager::registerAction(toggleViewAction,
Id(QLatin1String("Analyzer.") + dockWidget->objectName()), globalContext);
cmd->setAttribute(Command::CA_Hide);
ActionContainer *viewsMenu = am->actionContainer(Id(M_WINDOW_VIEWS));
ActionContainer *viewsMenu = Core::ActionManager::actionContainer(Id(M_WINDOW_VIEWS));
viewsMenu->addAction(cmd);
}
void AnalyzerManagerPrivate::deactivateDock(QDockWidget *dockWidget)
{
ActionManager *am = ICore::actionManager();
QAction *toggleViewAction = dockWidget->toggleViewAction();
am->unregisterAction(toggleViewAction, Id(QLatin1String("Analyzer.") + dockWidget->objectName()));
Core::ActionManager::unregisterAction(toggleViewAction, Id(QLatin1String("Analyzer.") + dockWidget->objectName()));
m_mainWindow->removeDockWidget(dockWidget);
dockWidget->hide();
// Prevent saveState storing the data of the wrong children.
......@@ -682,13 +678,12 @@ void AnalyzerManagerPrivate::addTool(IAnalyzerTool *tool, const StartModes &mode
delayedInit(); // Make sure that there is a valid IMode instance.
const bool blocked = m_toolBox->blockSignals(true); // Do not make current.
ActionManager *am = ICore::actionManager();
foreach (StartMode mode, modes) {
QString actionName = tool->actionName(mode);
Id menuGroup = tool->menuGroup(mode);
Id actionId = tool->actionId(mode);
QAction *action = new QAction(actionName, 0);
Command *command = am->registerAction(action, actionId, Context(C_GLOBAL));
Command *command = Core::ActionManager::registerAction(action, actionId, Context(C_GLOBAL));
m_menu->addAction(command, menuGroup);
command->action()->setData(int(StartLocal));
// Assuming this happens before project loading.
......
......@@ -155,8 +155,6 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
m_client = new BazaarClient(&m_bazaarSettings);
initializeVcs(new BazaarControl(m_client));
m_actionManager = Core::ICore::actionManager();
m_optionsPage = new OptionsPage();
addAutoReleasedObject(m_optionsPage);
m_bazaarSettings.readSettings(Core::ICore::settings());
......@@ -214,7 +212,7 @@ void BazaarPlugin::createMenu()
Core::Context context(Core::Constants::C_GLOBAL);
// Create menu item for Bazaar
m_bazaarContainer = m_actionManager->createMenu(Core::Id("Bazaar.BazaarMenu"));
m_bazaarContainer = Core::ActionManager::createMenu(Core::Id("Bazaar.BazaarMenu"));
QMenu *menu = m_bazaarContainer->menu();
menu->setTitle(tr("Bazaar"));
......@@ -226,7 +224,7 @@ void BazaarPlugin::createMenu()
createSeparator(context, Core::Id("Bazaar.Repository Management"));
// Request the Tools menu and add the Bazaar menu to it
Core::ActionContainer *toolsMenu = m_actionManager->actionContainer(Core::Id(Core::Constants::M_TOOLS));
Core::ActionContainer *toolsMenu = Core::ActionManager::actionContainer(Core::Id(Core::Constants::M_TOOLS));
toolsMenu->addMenu(m_bazaarContainer);
m_menuAction = m_bazaarContainer->menu()->menuAction();
}
......@@ -236,14 +234,14 @@ void BazaarPlugin::createFileActions(const Core::Context &context)
Core::Command *command;
m_annotateFile = new Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = m_actionManager->registerAction(m_annotateFile, Core::Id(Constants::ANNOTATE), context);
command = Core::ActionManager::registerAction(m_annotateFile, Core::Id(Constants::ANNOTATE), context);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_annotateFile, SIGNAL(triggered()), this, SLOT(annotateCurrentFile()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
m_diffFile = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = m_actionManager->registerAction(m_diffFile, Core::Id(Constants::DIFF), context);
command = Core::ActionManager::registerAction(m_diffFile, Core::Id(Constants::DIFF), context);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Z,Meta+D") : tr("ALT+Z,Alt+D")));
connect(m_diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
......@@ -251,7 +249,7 @@ void BazaarPlugin::createFileActions(const Core::Context &context)
m_commandLocator->appendCommand(command);
m_logFile = new Utils::ParameterAction(tr("Log Current File"), tr("Log \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = m_actionManager->registerAction(m_logFile, Core::Id(Constants::LOG), context);
command = Core::ActionManager::registerAction(m_logFile, Core::Id(Constants::LOG), context);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Z,Meta+L") : tr("ALT+Z,Alt+L")));
connect(m_logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile()));
......@@ -259,7 +257,7 @@ void BazaarPlugin::createFileActions(const Core::Context &context)
m_commandLocator->appendCommand(command);
m_statusFile = new Utils::ParameterAction(tr("Status Current File"), tr("Status \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = m_actionManager->registerAction(m_statusFile, Core::Id(Constants::STATUS), context);
command = Core::ActionManager::registerAction(m_statusFile, Core::Id(Constants::STATUS), context);
command->setAttribute(Core::Command::CA_UpdateText);
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Z,Meta+S") : tr("ALT+Z,Alt+S")));
connect(m_statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile()));
......@@ -269,21 +267,21 @@ void BazaarPlugin::createFileActions(const Core::Context &context)
createSeparator(context, Core::Id("Bazaar.FileDirSeperator1"));
m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = m_actionManager->registerAction(m_addAction, Core::Id(Constants::ADD), context);
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()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
m_deleteAction = new Utils::ParameterAction(tr("Delete..."), tr("Delete \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
command = m_actionManager->registerAction(m_deleteAction, Core::Id(Constants::DELETE), context);
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()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
m_revertFile = new Utils::ParameterAction(tr("Revert Current File..."), tr("Revert \"%1\"..."), Utils::ParameterAction::EnabledWithParameter, this);
command = m_actionManager->registerAction(m_revertFile, Core::Id(Constants::REVERT), context);
command = Core::ActionManager::registerAction(m_revertFile, Core::Id(Constants::REVERT), context);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_revertFile, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
m_bazaarContainer->addAction(command);
......@@ -348,28 +346,28 @@ void BazaarPlugin::createDirectoryActions(const Core::Context &context)
action = new QAction(tr("Diff"), this);
m_repositoryActionList.append(action);
command = m_actionManager->registerAction(action, Core::Id(Constants::DIFFMULTI), context);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::DIFFMULTI), context);
connect(action, SIGNAL(triggered()), this, SLOT(diffRepository()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Log"), this);
m_repositoryActionList.append(action);
command = m_actionManager->registerAction(action, Core::Id(Constants::LOGMULTI), context);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::LOGMULTI), context);
connect(action, SIGNAL(triggered()), this, SLOT(logRepository()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Revert..."), this);
m_repositoryActionList.append(action);
command = m_actionManager->registerAction(action, Core::Id(Constants::REVERTMULTI), context);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::REVERTMULTI), context);
connect(action, SIGNAL(triggered()), this, SLOT(revertAll()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Status"), this);
m_repositoryActionList.append(action);
command = m_actionManager->registerAction(action, Core::Id(Constants::STATUSMULTI), context);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::STATUSMULTI), context);
connect(action, SIGNAL(triggered()), this, SLOT(statusMulti()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
......@@ -419,35 +417,35 @@ void BazaarPlugin::createRepositoryActions(const Core::Context &context)
action = new QAction(tr("Pull..."), this);
m_repositoryActionList.append(action);
command = m_actionManager->registerAction(action, Core::Id(Constants::PULL), context);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::PULL), context);
connect(action, SIGNAL(triggered()), this, SLOT(pull()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Push..."), this);
m_repositoryActionList.append(action);
command = m_actionManager->registerAction(action, Core::Id(Constants::PUSH), context);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::PUSH), context);
connect(action, SIGNAL(triggered()), this, SLOT(push()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Update..."), this);
m_repositoryActionList.append(action);
command = m_actionManager->registerAction(action, Core::Id(Constants::UPDATE), context);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::UPDATE), context);
connect(action, SIGNAL(triggered()), this, SLOT(update()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
action = new QAction(tr("Commit..."), this);
m_repositoryActionList.append(action);
command = m_actionManager->registerAction(action, Core::Id(Constants::COMMIT), context);
command = Core::ActionManager::registerAction(action, Core::Id(Constants::COMMIT), context);
command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Z,Meta+C") : tr("ALT+Z,Alt+C")));
connect(action, SIGNAL(triggered()), this, SLOT(commit()));
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
QAction *createRepositoryAction = new QAction(tr("Create Repository..."), this);
command = m_actionManager->registerAction(createRepositoryAction, Core::Id(Constants::CREATE_REPOSITORY), context);
command = Core::ActionManager::registerAction(createRepositoryAction, Core::Id(Constants::CREATE_REPOSITORY), context);
connect(createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
m_bazaarContainer->addAction(command);
}
......@@ -514,18 +512,18 @@ void BazaarPlugin::createSubmitEditorActions()
Core::Command *command;
m_editorCommit = new QAction(VcsBase::VcsBaseSubmitEditor::submitIcon(), tr("Commit"), this);
command = m_actionManager->registerAction(m_editorCommit, Core::Id(Constants::COMMIT), context);
command = Core::ActionManager::registerAction(m_editorCommit, Core::Id(Constants::COMMIT), context);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_editorCommit, SIGNAL(triggered()), this, SLOT(commitFromEditor()));
m_editorDiff = new QAction(VcsBase::VcsBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this);
command = m_actionManager->registerAction(m_editorDiff, Core::Id(Constants::DIFFEDITOR), context);
command = Core::ActionManager::registerAction(m_editorDiff, Core::Id(Constants::DIFFEDITOR), context);
m_editorUndo = new QAction(tr("&Undo"), this);
command = m_actionManager->registerAction(m_editorUndo, Core::Id(Core::Constants::UNDO), context);
command = Core::ActionManager::registerAction(m_editorUndo, Core::Id(Core::Constants::UNDO), context);
m_editorRedo = new QAction(tr("&Redo"), this);
command = m_actionManager->registerAction(m_editorRedo, Core::Id(Core::Constants::REDO), context);
command = Core::ActionManager::registerAction(m_editorRedo, Core::Id(Core::Constants::REDO), context);
}
void BazaarPlugin::commit()
......@@ -682,7 +680,7 @@ void BazaarPlugin::createSeparator(const Core::Context &context, const Core::Id
{
QAction *action = new QAction(this);
action->setSeparator(true);
m_bazaarContainer->addAction(m_actionManager->registerAction(action, id, context));
m_bazaarContainer->addAction(Core::ActionManager::registerAction(action, id, context));
}
void BazaarPlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
......
......@@ -139,7 +139,6 @@ private:
BazaarClient *m_client;
Locator::CommandLocator *m_commandLocator;
Core::ActionManager *m_actionManager;
Core::ActionContainer *m_bazaarContainer;
QList<QAction *> m_repositoryActionList;
......
......@@ -464,7 +464,7 @@ BinEditorPlugin::~BinEditorPlugin()
QAction *BinEditorPlugin::registerNewAction(const QString &id, const QString &title)
{
QAction *result = new QAction(title, this);
Core::ICore::actionManager()->registerAction(result, Core::Id(id), m_context);
Core::ActionManager::registerAction(result, Core::Id(id), m_context);
return result;
}
......
......@@ -70,52 +70,51 @@ void BookmarksPlugin::extensionsInitialized()
bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
{
Core::ActionManager *am = Core::ICore::actionManager();
Core::Context textcontext(TextEditor::Constants::C_TEXTEDITOR);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::ActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS);
Core::ActionContainer *mbm = am->createMenu(Core::Id(BOOKMARKS_MENU));
Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS);
Core::ActionContainer *mbm = Core::ActionManager::createMenu(Core::Id(BOOKMARKS_MENU));
mbm->menu()->setTitle(tr("&Bookmarks"));
mtools->addMenu(mbm);
//Toggle
m_toggleAction = new QAction(tr("Toggle Bookmark"), this);
Core::Command *cmd =
am->registerAction(m_toggleAction, BOOKMARKS_TOGGLE_ACTION, textcontext);
Core::ActionManager::registerAction(m_toggleAction, BOOKMARKS_TOGGLE_ACTION, textcontext);
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+M") : tr("Ctrl+M")));
mbm->addAction(cmd);
QAction *sep = new QAction(this);
sep->setSeparator(true);
cmd = am->registerAction(sep, Core::Id("Bookmarks.Sep.Toggle"), textcontext);
cmd = Core::ActionManager::registerAction(sep, Core::Id("Bookmarks.Sep.Toggle"), textcontext);
mbm->addAction(cmd);
//Previous
m_prevAction = new QAction(tr("Previous Bookmark"), this);
cmd = am->registerAction(m_prevAction, BOOKMARKS_PREV_ACTION, globalcontext);
cmd = Core::ActionManager::registerAction(m_prevAction, BOOKMARKS_PREV_ACTION, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+,") : tr("Ctrl+,")));
mbm->addAction(cmd);
//Next
m_nextAction = new QAction(tr("Next Bookmark"), this);
cmd = am->registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION, globalcontext);
cmd = Core::ActionManager::registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+.")));
mbm->addAction(cmd);
sep = new QAction(this);
sep->setSeparator(true);
cmd = am->registerAction(sep, Core::Id("Bookmarks.Sep.DirNavigation"), globalcontext);
cmd = Core::ActionManager::registerAction(sep, Core::Id("Bookmarks.Sep.DirNavigation"), globalcontext);
mbm->addAction(cmd);
//Previous Doc
m_docPrevAction = new QAction(tr("Previous Bookmark in Document"), this);
cmd = am->registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION, globalcontext);
cmd = Core::ActionManager::registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION, globalcontext);
mbm->addAction(cmd);
//Next Doc
m_docNextAction = new QAction(tr("Next Bookmark in Document"), this);
cmd = am->registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION, globalcontext);
cmd = Core::ActionManager::registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION, globalcontext);
mbm->addAction(cmd);
m_bookmarkManager = new BookmarkManager;
......
......@@ -146,8 +146,7 @@ void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e)
{
QMenu *menu = new QMenu();
Core::ActionManager *am = Core::ICore::instance()->actionManager();
Core::ActionContainer *mcontext = am->actionContainer(Constants::M_CONTEXT);
Core::ActionContainer *mcontext = Core::ActionManager::actionContainer(Constants::M_CONTEXT);
QMenu *contextMenu = mcontext->menu();
foreach (QAction *action, contextMenu->actions())
......
......@@ -57,20 +57,19 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
TextEditorActionHandler::UnCommentSelection
| TextEditorActionHandler::JumpToFileUnderCursor);
ActionManager *am = ICore::actionManager();
ActionContainer *contextMenu = am->createMenu(Constants::M_CONTEXT);
ActionContainer *contextMenu = Core::ActionManager::createMenu(Constants::M_CONTEXT);
Command *cmd;
Context cmakeEditorContext = Context(Constants::C_CMAKEEDITOR);
cmd = am->command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR);
cmd = Core::ActionManager::command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR);
contextMenu->addAction(cmd);
QAction *separator = new QAction(this);
separator->setSeparator(true);
contextMenu->addAction(am->registerAction(separator,
contextMenu->addAction(Core::ActionManager::registerAction(separator,
Id(Constants::SEPARATOR), cmakeEditorContext));
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
cmd = Core::ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
}
......
......@@ -67,25 +67,25 @@ CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage)
connect(projectExplorer, SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*,ProjectExplorer::Node*)),
this, SLOT(updateContextMenu(ProjectExplorer::Project*,ProjectExplorer::Node*)));
Core::ActionManager *am = Core::ICore::actionManager();
Core::ActionContainer *mbuild =
am->actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT);
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT);
Core::ActionContainer *mproject =
am->actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT);
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT);
Core::ActionContainer *msubproject =
am->actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
const Core::Context projectContext(CMakeProjectManager::Constants::PROJECTCONTEXT);
m_runCMakeAction = new QAction(QIcon(), tr("Run CMake"), this);
Core::Command *command = am->registerAction(m_runCMakeAction, Constants::RUNCMAKE, projectContext);
Core::Command *command = Core::ActionManager::registerAction(m_runCMakeAction,
Constants::RUNCMAKE, projectContext);
command->setAttribute(Core::Command::CA_Hide);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_DEPLOY);
connect(m_runCMakeAction, SIGNAL(triggered()), this, SLOT(runCMake()));
m_runCMakeActionContextMenu = new QAction(QIcon(), tr("Run CMake"), this);
command = am->registerAction(m_runCMakeActionContextMenu, Constants::RUNCMAKECONTEXTMENU, projectContext);
command = Core::ActionManager::registerAction(m_runCMakeActionContextMenu,
Constants::RUNCMAKECONTEXTMENU, projectContext);
command->setAttribute(Core::Command::CA_Hide);
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
......
......@@ -30,6 +30,7 @@
**
**************************************************************************/
#include "actionmanager.h"
#include "actionmanager_p.h"
#include "mainwindow.h"
#include "actioncontainer_p.h"
......@@ -53,6 +54,9 @@ namespace {
enum { warnAboutFindFailures = 0 };
}
using namespace Core;
using namespace Core::Internal;
/*!
\class Core::ActionManager
\mainclass
......@@ -61,11 +65,8 @@ namespace {
menu items and keyboard shortcuts.
The ActionManager is the central bookkeeper of actions and their shortcuts and layout.
You get the only implementation of this class from the core interface
ICore::actionManager() method, e.g.
\code
Core::ICore::actionManager()
\endcode
It is a singleton containing mostly static methods. If you need access to the instance,
e.g. for connecting to signals, is its ActionManager::instance() method.
The main reasons for the need of this class is to provide a central place where the user
can specify all his keyboard shortcuts, and to provide a solution for actions that should
......@@ -73,7 +74,7 @@ namespace {
\section1 Contexts
All actions that are registered with the same string ID (but different context lists)
All actions that are registered with the same Id (but different context lists)
are considered to be overloads of the same command, represented by an instance
of the Command class.
Exactly only one of the registered actions with the same ID is active at any time.
......@@ -99,9 +100,8 @@ namespace {
To register a globally active action "My Action"
put the following in your plugin's IPlugin::initialize method:
\code
Core::ActionManager *am = Core::ICore::actionManager();
QAction *myAction = new QAction(tr("My Action"), this);
Core::Command *cmd = am->registerAction(myAction,
Core::Command *cmd = Core::ActionManager::registerAction(myAction,
"myplugin.myaction",
Core::Context(C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+u")));
......@@ -125,7 +125,7 @@ namespace {
Following the example adding "My Action" to the "Tools" menu would be done by
\code
am->actionContainer(Core::M_TOOLS)->addAction(cmd);
Core::ActionManager::actionContainer(Core::M_TOOLS)->addAction(cmd);
\endcode