Commit a66fe4b2 authored by hjk's avatar hjk

Core: Add an ActionContainer::addSeparator(Id) overload

This basically makes the Context parameter optional and default
to C_GLOBAL. Less noise on the user side.

Change-Id: Idaf1b83eabaf912450ab20bd5a8b613844bf69a2
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 8b9456e4
......@@ -244,10 +244,9 @@ void AnalyzerManagerPrivate::setupActions()
command = ActionManager::registerAction(m_stopAction, "Analyzer.Stop");
m_menu->addAction(command, G_ANALYZER_CONTROL);
const Context globalcontext(C_GLOBAL);
m_menu->addSeparator(globalcontext, G_ANALYZER_TOOLS);
m_menu->addSeparator(globalcontext, G_ANALYZER_REMOTE_TOOLS);
m_menu->addSeparator(globalcontext, G_ANALYZER_OPTIONS);
m_menu->addSeparator(G_ANALYZER_TOOLS);
m_menu->addSeparator(G_ANALYZER_REMOTE_TOOLS);
m_menu->addSeparator(G_ANALYZER_OPTIONS);
}
void AnalyzerManagerPrivate::delayedInit()
......
......@@ -568,4 +568,11 @@ bool MenuBarActionContainer::canBeAddedToMenu() const
}
} // namespace Internal
Command *ActionContainer::addSeparator(Id group)
{
static const Context context(Constants::C_GLOBAL);
return addSeparator(context, group);
}
} // namespace Core
......@@ -71,7 +71,8 @@ public:
virtual void addAction(Command *action, Id group = Id()) = 0;
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 = Context(), Id group = Id(), QAction **outSeparator = 0) = 0;
Command *addSeparator(Id group = Id());
virtual Command *addSeparator(const Context &context, 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.
......
......@@ -203,10 +203,9 @@ void FindPlugin::setupMenu()
mfind->appendGroup(Constants::G_FIND_FILTERS);
mfind->appendGroup(Constants::G_FIND_FLAGS);
mfind->appendGroup(Constants::G_FIND_ACTIONS);
Context globalcontext(Constants::C_GLOBAL);
Command *cmd;
mfind->addSeparator(globalcontext, Constants::G_FIND_FLAGS);
mfind->addSeparator(globalcontext, Constants::G_FIND_ACTIONS);
mfind->addSeparator(Constants::G_FIND_FLAGS);
mfind->addSeparator(Constants::G_FIND_ACTIONS);
ActionContainer *mfindadvanced = ActionManager::createMenu(Constants::M_FIND_ADVANCED);
mfindadvanced->menu()->setTitle(tr("Advanced Find"));
......
......@@ -468,18 +468,16 @@ void MainWindow::registerDefaultActions()
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
ActionContainer *mhelp = ActionManager::actionContainer(Constants::M_HELP);
Context globalContext(Constants::C_GLOBAL);
// File menu separators
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);
mfile->addSeparator(Constants::G_FILE_SAVE);
mfile->addSeparator(Constants::G_FILE_PRINT);
mfile->addSeparator(Constants::G_FILE_CLOSE);
mfile->addSeparator(Constants::G_FILE_OTHER);
// Edit menu separators
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);
medit->addSeparator(Constants::G_EDIT_COPYPASTE);
medit->addSeparator(Constants::G_EDIT_SELECTALL);
medit->addSeparator(Constants::G_EDIT_FIND);
medit->addSeparator(Constants::G_EDIT_ADVANCED);
// Return to editor shortcut: Note this requires Qt to fix up
// handling of shortcut overrides in menus, item views, combos....
......@@ -622,7 +620,7 @@ void MainWindow::registerDefaultActions()
// Options Action
mtools->appendGroup(Constants::G_TOOLS_OPTIONS);
mtools->addSeparator(globalContext, Constants::G_TOOLS_OPTIONS);
mtools->addSeparator(Constants::G_TOOLS_OPTIONS);
m_optionsAction = new QAction(tr("&Options..."), this);
m_optionsAction->setMenuRole(QAction::PreferencesRole);
......@@ -631,7 +629,7 @@ void MainWindow::registerDefaultActions()
mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS);
connect(m_optionsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog()));
mwindow->addSeparator(globalContext, Constants::G_WINDOW_LIST);
mwindow->addSeparator(Constants::G_WINDOW_LIST);
if (UseMacShortcuts) {
// Minimize Action
......@@ -659,7 +657,7 @@ void MainWindow::registerDefaultActions()
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
if (UseMacShortcuts) {
mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE);
mwindow->addSeparator(Constants::G_WINDOW_SIZE);
QAction *closeAction = new QAction(tr("Close Window"), this);
closeAction->setEnabled(false);
......@@ -667,7 +665,7 @@ void MainWindow::registerDefaultActions()
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Meta+W")));
mwindow->addAction(cmd, Constants::G_WINDOW_SIZE);
mwindow->addSeparator(globalContext, Constants::G_WINDOW_SIZE);
mwindow->addSeparator(Constants::G_WINDOW_SIZE);
}
// Show Sidebar Action
......@@ -695,9 +693,9 @@ void MainWindow::registerDefaultActions()
mviews->menu()->setTitle(tr("&Views"));
// "Help" separators
mhelp->addSeparator(globalContext, Constants::G_HELP_SUPPORT);
mhelp->addSeparator(Constants::G_HELP_SUPPORT);
if (!HostOsInfo::isMacHost())
mhelp->addSeparator(globalContext, Constants::G_HELP_ABOUT);
mhelp->addSeparator(Constants::G_HELP_ABOUT);
// About IDE Action
icon = QIcon::fromTheme(QLatin1String("help-about"));
......
......@@ -235,7 +235,7 @@ void OutputPaneManager::init()
connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
m_minMaxButton->setDefaultAction(cmd->action());
mpanes->addSeparator(Context(Constants::C_GLOBAL), "Coreplugin.OutputPane.ActionsGroup");
mpanes->addSeparator("Coreplugin.OutputPane.ActionsGroup");
QFontMetrics titleFm = m_titleLabel->fontMetrics();
int minTitleWidth = 0;
......
......@@ -3267,17 +3267,14 @@ DebuggerPlugin::~DebuggerPlugin()
bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
// Menu groups
const Context globalcontext(CC::C_GLOBAL);
ActionContainer *mstart = ActionManager::actionContainer(PE::M_DEBUG_STARTDEBUGGING);
mstart->appendGroup(Constants::G_GENERAL);
mstart->appendGroup(Constants::G_SPECIAL);
mstart->appendGroup(Constants::G_START_QML);
// Separators
mstart->addSeparator(globalcontext, Constants::G_GENERAL);
mstart->addSeparator(globalcontext, Constants::G_SPECIAL);
mstart->addSeparator(Constants::G_GENERAL);
mstart->addSeparator(Constants::G_SPECIAL);
addAutoReleasedObject(new DebuggerItemManager);
DebuggerItemManager::restoreDebuggers();
......
......@@ -541,7 +541,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
dd->m_proWindow = new ProjectWindow;
addAutoReleasedObject(dd->m_proWindow);
Context globalcontext(Core::Constants::C_GLOBAL);
Context projecTreeContext(Constants::C_PROJECT_TREE);
dd->m_projectsMode = new ProjectsMode(dd->m_proWindow);
......@@ -735,12 +734,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
msessionContextMenu->addSeparator(projecTreeContext, Constants::G_SESSION_FILES);
mprojectContextMenu->addSeparator(projecTreeContext, Constants::G_PROJECT_FILES);
msubProjectContextMenu->addSeparator(projecTreeContext, Constants::G_PROJECT_FILES);
mfile->addSeparator(globalcontext, Core::Constants::G_FILE_PROJECT);
mbuild->addSeparator(globalcontext, Constants::G_BUILD_REBUILD);
msessionContextMenu->addSeparator(globalcontext, Constants::G_SESSION_OTHER);
mbuild->addSeparator(globalcontext, Constants::G_BUILD_CANCEL);
mbuild->addSeparator(globalcontext, Constants::G_BUILD_RUN);
mprojectContextMenu->addSeparator(globalcontext, Constants::G_PROJECT_REBUILD);
mfile->addSeparator(Core::Constants::G_FILE_PROJECT);
mbuild->addSeparator(Constants::G_BUILD_REBUILD);
msessionContextMenu->addSeparator(Constants::G_SESSION_OTHER);
mbuild->addSeparator(Constants::G_BUILD_CANCEL);
mbuild->addSeparator(Constants::G_BUILD_RUN);
mprojectContextMenu->addSeparator(Constants::G_PROJECT_REBUILD);
//
// Actions
......@@ -1055,15 +1054,15 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
cmd = ActionManager::registerAction(dd->m_projectTreeCollapseAllAction, Constants::PROJECTTREE_COLLAPSE_ALL,
projecTreeContext);
const Id treeGroup = Constants::G_PROJECT_TREE;
mfileContextMenu->addSeparator(globalcontext, treeGroup);
mfileContextMenu->addSeparator(treeGroup);
mfileContextMenu->addAction(cmd, treeGroup);
msubProjectContextMenu->addSeparator(globalcontext, treeGroup);
msubProjectContextMenu->addSeparator(treeGroup);
msubProjectContextMenu->addAction(cmd, treeGroup);
mfolderContextMenu->addSeparator(globalcontext, treeGroup);
mfolderContextMenu->addSeparator(treeGroup);
mfolderContextMenu->addAction(cmd, treeGroup);
mprojectContextMenu->addSeparator(globalcontext, treeGroup);
mprojectContextMenu->addSeparator(treeGroup);
mprojectContextMenu->addAction(cmd, treeGroup);
msessionContextMenu->addSeparator(globalcontext, treeGroup);
msessionContextMenu->addSeparator(treeGroup);
msessionContextMenu->addAction(cmd, treeGroup);
// target selector
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment