Commit cdd44bef authored by Eike Ziller's avatar Eike Ziller Committed by hjk

Add ActionContainer::addSeparator(...)

Gets rid of a lot of code duplication.

Change-Id: I2ce38fb38a0b61cb821e0bdc7bcc9a7ccdf9da72
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent d90264d6
......@@ -286,23 +286,9 @@ void AnalyzerManagerPrivate::setupActions()
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 = 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 = 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 = Core::ActionManager::registerAction(separatorAction3,
"Menu.Action.Analyzer.Tools.Separator3", globalcontext);
m_menu->addAction(command, G_ANALYZER_OPTIONS);
m_menu->addSeparator(globalcontext, G_ANALYZER_TOOLS);
m_menu->addSeparator(globalcontext, G_ANALYZER_REMOTE_TOOLS);
m_menu->addSeparator(globalcontext, G_ANALYZER_OPTIONS);
}
void AnalyzerManagerPrivate::delayedInit()
......
......@@ -217,11 +217,11 @@ void BazaarPlugin::createMenu()
menu->setTitle(tr("Bazaar"));
createFileActions(context);
createSeparator(context, Core::Id("Bazaar.FileDirSeperator"));
m_bazaarContainer->addSeparator(context);
createDirectoryActions(context);
createSeparator(context, Core::Id("Bazaar.DirRepoSeperator"));
m_bazaarContainer->addSeparator(context);
createRepositoryActions(context);
createSeparator(context, Core::Id("Bazaar.Repository Management"));
m_bazaarContainer->addSeparator(context);
// Request the Tools menu and add the Bazaar menu to it
Core::ActionContainer *toolsMenu = Core::ActionManager::actionContainer(Core::Id(Core::Constants::M_TOOLS));
......@@ -264,7 +264,7 @@ void BazaarPlugin::createFileActions(const Core::Context &context)
m_bazaarContainer->addAction(command);
m_commandLocator->appendCommand(command);
createSeparator(context, Core::Id("Bazaar.FileDirSeperator1"));
m_bazaarContainer->addSeparator(context);
m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = Core::ActionManager::registerAction(m_addAction, Core::Id(Constants::ADD), context);
......@@ -676,13 +676,6 @@ void BazaarPlugin::deleteCommitLog()
}
}
void BazaarPlugin::createSeparator(const Core::Context &context, const Core::Id &id)
{
QAction *action = new QAction(this);
action->setSeparator(true);
m_bazaarContainer->addAction(Core::ActionManager::registerAction(action, id, context));
}
void BazaarPlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
{
if (!enableMenuAction(as, m_menuAction)) {
......
......@@ -126,7 +126,6 @@ private:
// Methods
void createMenu();
void createSubmitEditorActions();
void createSeparator(const Core::Context &context, const Core::Id &id);
void createFileActions(const Core::Context &context);
void createDirectoryActions(const Core::Context &context);
void createRepositoryActions(const Core::Context &context);
......
......@@ -85,10 +85,7 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+M") : tr("Ctrl+M")));
mbm->addAction(cmd);
QAction *sep = new QAction(this);
sep->setSeparator(true);
cmd = Core::ActionManager::registerAction(sep, Core::Id("Bookmarks.Sep.Toggle"), textcontext);
mbm->addAction(cmd);
mbm->addSeparator(textcontext);
//Previous
m_prevAction = new QAction(tr("Previous Bookmark"), this);
......@@ -102,10 +99,7 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+.")));
mbm->addAction(cmd);
sep = new QAction(this);
sep->setSeparator(true);
cmd = Core::ActionManager::registerAction(sep, Core::Id("Bookmarks.Sep.DirNavigation"), globalcontext);
mbm->addAction(cmd);
mbm->addSeparator(globalcontext);
//Previous Doc
m_docPrevAction = new QAction(tr("Previous Bookmark in Document"), this);
......
......@@ -64,10 +64,7 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager)
cmd = Core::ActionManager::command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR);
contextMenu->addAction(cmd);
QAction *separator = new QAction(this);
separator->setSeparator(true);
contextMenu->addAction(Core::ActionManager::registerAction(separator,
Id(Constants::SEPARATOR), cmakeEditorContext));
contextMenu->addSeparator(cmakeEditorContext);
cmd = Core::ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION);
contextMenu->addAction(cmd);
......
......@@ -50,9 +50,6 @@ const char CMAKEPROJECT_ID[] = "CMakeProjectManager.CMakeProject";
// Menu
const char M_CONTEXT[] = "CMakeEditor.ContextMenu";
// Actions
const char SEPARATOR[] = "CMakeEditor.Separator";
} // namespace Constants
} // namespace CMakeProjectManager
......
......@@ -32,6 +32,7 @@
#include "actioncontainer_p.h"
#include "actionmanager_p.h"
#include "actionmanager.h"
#include "command_p.h"
......@@ -293,6 +294,31 @@ void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *m
scheduleUpdate();
}
/*!
* \fn Command *ActionContainer::addSeparator(const Context &context, const Id &group, QAction **outSeparator)
*
* Adds a separator to the end of the given \a group to the action container, which is enabled
* for a given \a context. The created separator action is returned through \a outSeparator.
*
* Returns the created Command for the separator.
*/
/*! \a context \a group \a outSeparator
* \internal
*/
Command *ActionContainerPrivate::addSeparator(const Context &context, const Id &group, QAction **outSeparator)
{
static int separatorIdCount = 0;
QAction *separator = new QAction(this);
separator->setSeparator(true);
Command *cmd = ActionManager::registerAction(separator, Id(QString::fromLatin1("%1.Separator.%2")
.arg(id().toString()).arg(++separatorIdCount)),
context);
addAction(cmd, group);
if (outSeparator)
*outSeparator = separator;
return cmd;
}
void ActionContainerPrivate::clear()
{
QMutableListIterator<Group> it(m_groups);
......
......@@ -34,6 +34,7 @@
#define ACTIONCONTAINER_H
#include "coreplugin/id.h"
#include "coreplugin/icontext.h"
#include <QObject>
......@@ -72,6 +73,7 @@ public:
virtual void addAction(Command *action, const Id &group = Id()) = 0;
virtual void addMenu(ActionContainer *menu, const Id &group = Id()) = 0;
virtual void addMenu(ActionContainer *before, ActionContainer *menu, const Id &group = Id()) = 0;
virtual Command *addSeparator(const Context &context, const Id &group = Id(), QAction **outSeparator = 0) = 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.
......
......@@ -65,6 +65,7 @@ public:
void addAction(Command *action, const Id &group = Id());
void addMenu(ActionContainer *menu, const Id &group = Id());
void addMenu(ActionContainer *before, ActionContainer *menu, const Id &group = Id());
Command *addSeparator(const Context &context, const Id &group = Id(), QAction **outSeparator = 0);
virtual void clear();
Id id() const;
......
......@@ -265,16 +265,6 @@ Id CommandPrivate::id() const
return m_id;
}
QAction *CommandPrivate::action() const
{
return 0;
}
QShortcut *CommandPrivate::shortcut() const
{
return 0;
}
Core::Context CommandPrivate::context() const
{
return m_context;
......
......@@ -66,8 +66,6 @@ public:
Id id() const;
QAction *action() const;
QShortcut *shortcut() const;
Context context() const;
......@@ -100,6 +98,8 @@ public:
void setShortcut(QShortcut *shortcut);
QShortcut *shortcut() const;
QAction *action() const { return 0; }
void setContext(const Context &context);
Context context() const;
void setCurrentContext(const Context &context);
......@@ -125,6 +125,7 @@ public:
QKeySequence keySequence() const;
QAction *action() const;
QShortcut *shortcut() const { return 0; }
void setCurrentContext(const Context &context);
bool isActive() const;
......
......@@ -274,15 +274,6 @@ static EditorManager *m_instance = 0;
EditorManager *EditorManager::instance() { return m_instance; }
static Command *createSeparator(QObject *parent,
const Id &id, const Context &context)
{
QAction *tmpaction = new QAction(parent);
tmpaction->setSeparator(true);
Command *cmd = ActionManager::registerAction(tmpaction, id, context);
return cmd;
}
EditorManager::EditorManager(QWidget *parent) :
QWidget(parent),
d(new EditorManagerPrivate(parent))
......@@ -319,15 +310,8 @@ EditorManager::EditorManager(QWidget *parent) :
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
// Window menu separators
QAction *tmpaction = new QAction(this);
tmpaction->setSeparator(true);
cmd = ActionManager::registerAction(tmpaction, "QtCreator.Window.Sep.Split", editManagerContext);
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
tmpaction = new QAction(this);
tmpaction->setSeparator(true);
cmd = ActionManager::registerAction(tmpaction, "QtCreator.Window.Sep.Navigate", editManagerContext);
mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE);
mwindow->addSeparator(editManagerContext, Constants::G_WINDOW_SPLIT);
mwindow->addSeparator(editManagerContext, Constants::G_WINDOW_NAVIGATE);
// Close Action
cmd = ActionManager::registerAction(d->m_closeCurrentEditorAction, Constants::CLOSE, editManagerContext, true);
......@@ -431,14 +415,10 @@ EditorManager::EditorManager(QWidget *parent) :
advancedMenu->appendGroup(Constants::G_EDIT_EDITOR);
// Advanced menu separators
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Collapsing"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_COLLAPSING);
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Blocks"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_BLOCKS);
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Font"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_FONT);
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Editor"), editManagerContext);
advancedMenu->addAction(cmd, Constants::G_EDIT_EDITOR);
advancedMenu->addSeparator(editManagerContext, Constants::G_EDIT_COLLAPSING);
advancedMenu->addSeparator(editManagerContext, Constants::G_EDIT_BLOCKS);
advancedMenu->addSeparator(editManagerContext, Constants::G_EDIT_FONT);
advancedMenu->addSeparator(editManagerContext, Constants::G_EDIT_EDITOR);
// other setup
d->m_splitter = new SplitterOrView(d->m_editorModel);
......
......@@ -548,15 +548,6 @@ void MainWindow::registerDefaultContainers()
ac->appendGroup(Constants::G_HELP_ABOUT);
}
static Command *createSeparator(QObject *parent,
const Id &id, const Context &context)
{
QAction *tmpaction = new QAction(parent);
tmpaction->setSeparator(true);
Command *cmd = ActionManager::registerAction(tmpaction, id, context);
return cmd;
}
void MainWindow::registerDefaultActions()
{
ActionContainer *mfile = ActionManager::actionContainer(Constants::M_FILE);
......@@ -568,41 +559,25 @@ void MainWindow::registerDefaultActions()
Context globalContext(Constants::C_GLOBAL);
// File menu separators
Command *cmd = createSeparator(this, Id("QtCreator.File.Sep.Save"), globalContext);
mfile->addAction(cmd, Constants::G_FILE_SAVE);
cmd = createSeparator(this, Id("QtCreator.File.Sep.Print"), globalContext);
QIcon icon = QIcon::fromTheme(QLatin1String("edit-cut"), QIcon(QLatin1String(Constants::ICON_CUT)));
mfile->addAction(cmd, Constants::G_FILE_PRINT);
cmd = createSeparator(this, Id("QtCreator.File.Sep.Close"), globalContext);
mfile->addAction(cmd, Constants::G_FILE_CLOSE);
cmd = createSeparator(this, Id("QtCreator.File.Sep.Other"), globalContext);
mfile->addAction(cmd, Constants::G_FILE_OTHER);
mfile->addSeparator(globalContext, Constants::G_FILE_SAVE);
mfile->addSeparator(globalContext, Constants::G_FILE_PRINT);
mfile->addSeparator(globalContext, Constants::G_FILE_CLOSE);
mfile->addSeparator(globalContext, Constants::G_FILE_OTHER);
// Edit menu separators
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.CopyPaste"), globalContext);
medit->addAction(cmd, Constants::G_EDIT_COPYPASTE);
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.SelectAll"), globalContext);
medit->addAction(cmd, Constants::G_EDIT_SELECTALL);
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Find"), globalContext);
medit->addAction(cmd, Constants::G_EDIT_FIND);
cmd = createSeparator(this, Id("QtCreator.Edit.Sep.Advanced"), globalContext);
medit->addAction(cmd, Constants::G_EDIT_ADVANCED);
medit->addSeparator(globalContext, Constants::G_EDIT_COPYPASTE);
medit->addSeparator(globalContext, Constants::G_EDIT_SELECTALL);
medit->addSeparator(globalContext, Constants::G_EDIT_FIND);
medit->addSeparator(globalContext, Constants::G_EDIT_ADVANCED);
// Return to editor shortcut: Note this requires Qt to fix up
// handling of shortcut overrides in menus, item views, combos....
m_focusToEditor = new QShortcut(this);
cmd = ActionManager::registerShortcut(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext);
Command *cmd = ActionManager::registerShortcut(m_focusToEditor, Constants::S_RETURNTOEDITOR, globalContext);
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_Escape));
connect(m_focusToEditor, SIGNAL(activated()), this, SLOT(setFocusToEditor()));
// New File Action
icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE)));
QIcon icon = QIcon::fromTheme(QLatin1String("document-new"), QIcon(QLatin1String(Constants::ICON_NEWFILE)));
m_newAction = new QAction(icon, tr("&New File or Project..."), this);
cmd = ActionManager::registerAction(m_newAction, Constants::NEW, globalContext);
cmd->setDefaultKeySequence(QKeySequence::New);
......@@ -734,8 +709,7 @@ void MainWindow::registerDefaultActions()
// Options Action
mtools->appendGroup(Constants::G_TOOLS_OPTIONS);
cmd = createSeparator(this, Id("QtCreator.Tools.Sep.Options"), globalContext);
mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS);
mtools->addSeparator(globalContext, Constants::G_TOOLS_OPTIONS);
m_optionsAction = new QAction(tr("&Options..."), this);
cmd = ActionManager::registerAction(m_optionsAction, Constants::OPTIONS, globalContext);
if (UseMacShortcuts) {
......@@ -760,8 +734,7 @@ void MainWindow::registerDefaultActions()
connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized()));
// Window separator
cmd = createSeparator(this, Id("QtCreator.Window.Sep.Size"), globalContext);
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE);
}
// Show Sidebar Action
......
......@@ -242,10 +242,7 @@ void OutputPaneManager::init()
connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
m_minMaxButton->setDefaultAction(cmd->action());
QAction *sep = new QAction(this);
sep->setSeparator(true);
cmd = ActionManager::registerAction(sep, "Coreplugin.OutputPane.Sep", globalContext);
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
mpanes->addSeparator(globalContext, "Coreplugin.OutputPane.ActionsGroup");
QFontMetrics titleFm = m_titleLabel->fontMetrics();
int minTitleWidth = 0;
......
......@@ -44,10 +44,6 @@ const char SWITCH_DECLARATION_DEFINITION[] = "CppEditor.SwitchDeclarationDefinit
const char RENAME_SYMBOL_UNDER_CURSOR[] = "CppEditor.RenameSymbolUnderCursor";
const char FIND_USAGES[] = "CppEditor.FindUsages";
const char M_REFACTORING_MENU_INSERTION_POINT[] = "CppEditor.RefactorGroup";
const char SEPARATOR[] = "CppEditor.Separator";
const char SEPARATOR2[] = "CppEditor.Separator2";
const char SEPARATOR3[] = "CppEditor.Separator3";
const char SEPARATOR4[] = "CppEditor.Separator4";
const char UPDATE_CODEMODEL[] = "CppEditor.UpdateCodeModel";
const int TYPE_HIERARCHY_PRIORITY = 700;
......
......@@ -123,16 +123,6 @@ QStringList CppEditorFactory::mimeTypes() const
///////////////////////////////// CppPlugin //////////////////////////////////
static inline
Core::Command *createSeparator(QObject *parent,
Core::Context &context,
const char *id)
{
QAction *separator = new QAction(parent);
separator->setSeparator(true);
return Core::ActionManager::registerAction(separator, Core::Id(id), context);
}
CppPlugin *CppPlugin::m_instance = 0;
CppPlugin::CppPlugin() :
......@@ -263,12 +253,9 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
// Refactoring sub-menu
Core::Context globalContext(Core::Constants::C_GLOBAL);
Core::Command *sep = createSeparator(this, globalContext,
Constants::SEPARATOR2);
Core::Command *sep = contextMenu->addSeparator(globalContext);
sep->action()->setObjectName(QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT));
contextMenu->addAction(sep);
contextMenu->addAction(createSeparator(this, globalContext,
Constants::SEPARATOR3));
contextMenu->addSeparator(globalContext);
m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol Under Cursor"),
this);
......@@ -281,7 +268,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
cppToolsMenu->addAction(cmd);
// Update context in global context
cppToolsMenu->addAction(createSeparator(this, globalContext, CppEditor::Constants::SEPARATOR4));
cppToolsMenu->addSeparator(globalContext);
m_updateCodeModelAction = new QAction(tr("Update Code Model"), this);
cmd = Core::ActionManager::registerAction(m_updateCodeModelAction, Core::Id(Constants::UPDATE_CODEMODEL), globalContext);
CPlusPlus::CppModelManagerInterface *cppModelManager = CPlusPlus::CppModelManagerInterface::instance();
......@@ -296,7 +283,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
m_actionHandler->initializeActions();
contextMenu->addAction(createSeparator(this, context, CppEditor::Constants::SEPARATOR));
contextMenu->addSeparator(context);
cmd = Core::ActionManager::command(TextEditor::Constants::AUTO_INDENT_SELECTION);
contextMenu->addAction(cmd);
......
......@@ -98,14 +98,11 @@ static const char CMD_ID_EDIT_FILE[] = "CVS.EditFile";
static const char CMD_ID_UNEDIT_FILE[] = "CVS.UneditFile";
static const char CMD_ID_UNEDIT_REPOSITORY[] = "CVS.UneditRepository";
static const char CMD_ID_REVERT[] = "CVS.Revert";
static const char CMD_ID_SEPARATOR0[] = "CVS.Separator0";
static const char CMD_ID_DIFF_PROJECT[] = "CVS.DiffAll";
static const char CMD_ID_DIFF_CURRENT[] = "CVS.DiffCurrent";
static const char CMD_ID_SEPARATOR1[] = "CVS.Separator1";
static const char CMD_ID_COMMIT_ALL[] = "CVS.CommitAll";
static const char CMD_ID_REVERT_ALL[] = "CVS.RevertAll";
static const char CMD_ID_COMMIT_CURRENT[] = "CVS.CommitCurrent";
static const char CMD_ID_SEPARATOR2[] = "CVS.Separator2";
static const char CMD_ID_FILELOG_CURRENT[] = "CVS.FilelogCurrent";
static const char CMD_ID_ANNOTATE_CURRENT[] = "CVS.AnnotateCurrent";
static const char CMD_ID_STATUS[] = "CVS.Status";
......@@ -116,7 +113,6 @@ static const char CMD_ID_REPOSITORYLOG[] = "CVS.RepositoryLog";
static const char CMD_ID_REPOSITORYDIFF[] = "CVS.RepositoryDiff";
static const char CMD_ID_REPOSITORYSTATUS[] = "CVS.RepositoryStatus";
static const char CMD_ID_REPOSITORYUPDATE[] = "CVS.RepositoryUpdate";
static const char CMD_ID_SEPARATOR3[] = "CVS.Separator3";
static const VcsBaseEditorParameters editorParameters[] = {
{
......@@ -223,15 +219,6 @@ static const VcsBaseSubmitEditorParameters submitParameters = {
Constants::CVSCOMMITEDITOR
};
static Command *createSeparator(QObject *parent,
const char *id,
const Context &globalcontext)
{
QAction *tmpaction = new QAction(parent);
tmpaction->setSeparator(true);
return Core::ActionManager::registerAction(tmpaction, id, globalcontext);
}
bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
Q_UNUSED(arguments);
......@@ -306,7 +293,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
cvsMenu->addAction(createSeparator(this, CMD_ID_SEPARATOR0, globalcontext));
cvsMenu->addSeparator(globalcontext);
m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = Core::ActionManager::registerAction(m_addAction, CMD_ID_ADD,
......@@ -342,7 +329,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
cvsMenu->addAction(createSeparator(this, CMD_ID_SEPARATOR1, globalcontext));
cvsMenu->addSeparator(globalcontext);
m_editCurrentAction = new Utils::ParameterAction(tr("Edit"), tr("Edit \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = Core::ActionManager::registerAction(m_editCurrentAction, CMD_ID_EDIT_FILE, globalcontext);
......@@ -364,7 +351,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
cvsMenu->addAction(createSeparator(this, CMD_ID_SEPARATOR2, globalcontext));
cvsMenu->addSeparator(globalcontext);
m_diffProjectAction = new Utils::ParameterAction(tr("Diff Project"), tr("Diff Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this);
command = Core::ActionManager::registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT,
......@@ -403,7 +390,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
cvsMenu->addAction(command);
m_commandLocator->appendCommand(command);
cvsMenu->addAction(createSeparator(this, CMD_ID_SEPARATOR3, globalcontext));
cvsMenu->addSeparator(globalcontext);
m_diffRepositoryAction = new QAction(tr("Diff Repository"), this);
command = Core::ActionManager::registerAction(m_diffRepositoryAction, CMD_ID_REPOSITORYDIFF, globalcontext);
......
......@@ -3200,11 +3200,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
mstart->addAction(cmd, Constants::G_MANUAL_REMOTE);
}
QAction *sep = new QAction(mstart);
sep->setSeparator(true);
cmd = Core::ActionManager::registerAction(sep,
"Debugger.Start.Qml", globalcontext);
mstart->addAction(cmd, Constants::G_START_QML);
mstart->addSeparator(globalcontext, Constants::G_START_QML);
cmd = Core::ActionManager::registerAction(m_attachToQmlPortAction,
"Debugger.AttachToQmlPort", globalcontext);
......@@ -3243,10 +3239,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
cmd->setDescription(tr("Reset Debugger"));
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
sep = new QAction(this);
sep->setSeparator(true);
cmd = Core::ActionManager::registerAction(sep, "Debugger.Sep.Step", globalcontext);
debugMenu->addAction(cmd);
debugMenu->addSeparator(globalcontext);
cmd = Core::ActionManager::registerAction(m_nextAction,
Constants::NEXT, globalcontext);
......@@ -3298,10 +3291,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
cmd->setAttribute(Command::CA_Hide);
debugMenu->addAction(cmd);
sep = new QAction(this);
sep->setSeparator(true);
cmd = Core::ActionManager::registerAction(sep, "Debugger.Sep.Break", globalcontext);
debugMenu->addAction(cmd);
debugMenu->addSeparator(globalcontext);
//cmd = Core::ActionManager::registerAction(m_snapshotAction,
// "Debugger.Snapshot", cppDebuggercontext);
......@@ -3326,10 +3316,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
connect(m_breakAction, SIGNAL(triggered()),
SLOT(toggleBreakpoint()));
sep = new QAction(this);
sep->setSeparator(true);
cmd = Core::ActionManager::registerAction(sep, "Debugger.Sep.Watch", globalcontext);
debugMenu->addAction(cmd);
debugMenu->addSeparator(globalcontext);
// Don't add '1' to the string as it shows up in the shortcut dialog.
cmd = Core::ActionManager::registerAction(m_watchAction1,
......@@ -3341,9 +3328,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
// the editor context menu.
if (ActionContainer *editorContextMenu =
Core::ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT)) {
cmd = Core::ActionManager::registerAction(sep, "Debugger.Sep.Views",
cppDebuggercontext);
editorContextMenu->addAction(cmd);
cmd = editorContextMenu->addSeparator(cppDebuggercontext);
cmd->setAttribute(Command::CA_Hide);
cmd = Core::ActionManager::registerAction(m_watchAction2,
......@@ -3590,20 +3575,9 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
mstart->appendGroup(Constants::G_START_QML);
// Separators
QAction *sep = new QAction(mstart);
sep->setSeparator(true);
Command *cmd = Core::ActionManager::registerAction(sep, "Debugger.Local.Cpp", globalcontext);
mstart->addAction(cmd, Constants::G_START_LOCAL);
sep = new QAction(mstart);
sep->setSeparator(true);
cmd = Core::ActionManager::registerAction(sep, "Debugger.StartRemote.Cpp", globalcontext);
mstart->addAction(cmd, Constants::G_MANUAL_REMOTE);
sep = new QAction(mstart);
sep->setSeparator(true);
cmd = Core::ActionManager::registerAction(sep, "Debugger.AttachRemote.Cpp", globalcontext);
mstart->addAction(cmd, Constants::G_AUTOMATIC_REMOTE);
mstart->addSeparator(globalcontext, Constants::G_START_LOCAL);
mstart->addSeparator(globalcontext, Constants::G_MANUAL_REMOTE);
mstart->addSeparator(globalcontext, Constants::G_AUTOMATIC_REMOTE);
return theDebuggerCore->initialize(arguments, errorMessage);
}
......
......@@ -125,20 +125,6 @@ static inline QIcon designerIcon(const QString &iconName)
return icon;
}
// Create a menu separator
static QAction *createSeparator(QObject *parent,
const Core::Context &context,
Core::ActionContainer *container,
const Core::Id &id,
const Core::Id &group = Core::Id())
{
QAction *actSeparator = new QAction(parent);
actSeparator->setSeparator(true);
Core::Command *command = Core::ActionManager::registerAction(actSeparator, id, context);
container->addAction(command, group);
return actSeparator;
}
using namespace Designer::Constants;
namespace Designer {
......@@ -462,10 +448,7 @@ void FormEditorW::setupActions()
m_actionGroupEditMode->setExclusive(true);
connect(m_actionGroupEditMode, SIGNAL(triggered(QAction*)), this, SLOT(activateEditMode(QAction*)));
m_modeActionSeparator = new QAction(this);
m_modeActionSeparator->setSeparator(true);
command = Core::ActionManager::registerAction(m_modeActionSeparator, Core::Id("FormEditor.Sep.ModeActions"), m_contexts);
medit->addAction(command, Core::Constants::G_EDIT_OTHER);
medit->addSeparator(m_contexts, Core::Constants::G_EDIT_OTHER);
m_toolActionIds.push_back(Core::Id("FormEditor.WidgetEditor"));
createEditModeAction(m_actionGroupEditMode, m_contexts, medit,
......@@ -528,7 +511,7 @@ void FormEditorW::setupActions()
addToolAction(m_fwm->actionSimplifyLayout(), m_contexts,
m_toolActionIds.back(), mformtools);
createSeparator(this, m_contexts, mformtools, Core::Id("FormEditor.Menu.Tools.Separator1"));
mformtools->addSeparator(m_contexts);
addToolAction(m_fwm->actionLower(), m_contexts,
Core::Id("FormEditor.Lower"), mformtools);
......@@ -537,7 +520,7 @@ void FormEditorW::setupActions()
Core::Id("FormEditor.Raise"), mformtools);
// Commands that do not go into the editor toolbar
createSeparator(this, m_contexts, mformtools, Core::Id("FormEditor.Menu.Tools.Separator2"));
mformtools->addSeparator(m_contexts);
#if QT_VERSION >= 0x050000
m_actionPreview = m_fwm->action(QDesignerFormWindowManagerInterface::DefaultPreviewAction);
......@@ -561,9 +544,9 @@ void FormEditorW::setupActions()
setPreviewMenuEnabled(false);
// Form settings
createSeparator(this, m_contexts, medit, Core::Id("FormEditor.Edit.Separator2"), Core::Constants::G_EDIT_OTHER);
medit->addSeparator(m_contexts, Core::Constants::G_EDIT_OTHER);
createSeparator(this, m_contexts, mformtools, Core::Id("FormEditor.Menu.Tools.Separator3"));
mformtools->addSeparator(m_contexts);
m_actionSwitchSource = new QAction(tr("Switch Source/Form"), this);
connect(m_actionSwitchSource, SIGNAL(triggered()), this, SLOT(switchSourceForm()));
......@@ -574,7 +557,7 @@ void FormEditorW::setupActions()
addToolAction(m_actionSwitchSource, switchContexts, Core::Id("FormEditor.FormSwitchSource"), mformtools,
tr("Shift+F4"));
createSeparator(this, m_contexts, mformtools, Core::Id("FormEditor.Menu.Tools.Separator4"));