Commit c43f3c84 authored by hjk's avatar hjk Committed by hjk
Browse files

analyze: create a top level menu entry

Change-Id: I17c4d17583d401fb537d5956f5b07a1dc12906e1
Reviewed-on: http://codereview.qt.nokia.com/893

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent e9a7ec27
......@@ -279,26 +279,23 @@ void AnalyzerManager::AnalyzerManagerPrivate::setupActions()
{
Core::ICore *core = Core::ICore::instance();
Core::ActionManager *am = core->actionManager();
Core::ActionContainer *mtools = am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
m_menu = am->createMenu(Constants::M_DEBUG_ANALYZER);
const Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::Command *command = 0;
// add separator before Analyzer menu
QAction *act = new QAction(m_menu);
act->setSeparator(true);
command = am->registerAction(act, "Analyzer.Action.Sep", globalcontext);
mtools->addAction(command);
m_menu = am->createMenu(Constants::M_DEBUG_ANALYZER);
// Menus
m_menu->menu()->setTitle(tr("Start &Analyzer"));
m_menu->menu()->setTitle(tr("&Analyze"));
m_menu->menu()->setEnabled(true);
m_menu->appendGroup(Constants::G_ANALYZER_STARTSTOP);
m_menu->appendGroup(Constants::G_ANALYZER_TOOLS);
mtools->addMenu(m_menu);
Core::ActionContainer *menubar =
am->actionContainer(Core::Constants::MENU_BAR);
Core::ActionContainer *mtools =
am->actionContainer(Core::Constants::M_TOOLS);
menubar->addMenu(mtools, m_menu);
m_toolGroup = new QActionGroup(m_menu);
connect(m_toolGroup, SIGNAL(triggered(QAction*)),
......@@ -306,8 +303,7 @@ void AnalyzerManager::AnalyzerManagerPrivate::setupActions()
m_startAction = new QAction(tr("Start"), m_menu);
m_startAction->setIcon(QIcon(Constants::ANALYZER_CONTROL_START_ICON));
command = am->registerAction(m_startAction,
Constants::START, globalcontext);
command = am->registerAction(m_startAction, Constants::START, globalcontext);
m_menu->addAction(command, Constants::G_ANALYZER_STARTSTOP);
connect(m_startAction, SIGNAL(triggered()), q, SLOT(startTool()));
......
......@@ -272,6 +272,29 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group
scheduleUpdate();
}
void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *menu, const QString &groupId)
{
ActionContainerPrivate *containerPrivate = static_cast<ActionContainerPrivate *>(menu);
if (!containerPrivate->canBeAddedToMenu())
return;
MenuActionContainer *container = static_cast<MenuActionContainer *>(containerPrivate);
QString actualGroupId;
if (groupId.isEmpty())
actualGroupId = QLatin1String(Constants::G_DEFAULT_TWO);
else
actualGroupId = groupId;
QList<Group>::const_iterator groupIt = findGroup(actualGroupId);
QTC_ASSERT(groupIt != m_groups.constEnd(), return);
QAction *beforeAction = before->menu()->menuAction();
m_groups[groupIt-m_groups.constBegin()].items.append(menu);
connect(menu, SIGNAL(destroyed()), this, SLOT(itemDestroyed()));
insertMenu(beforeAction, container->menu());
scheduleUpdate();
}
void ActionContainerPrivate::clear()
{
QMutableListIterator<Group> it(m_groups);
......
......@@ -68,6 +68,7 @@ public:
virtual void appendGroup(const QString &group) = 0;
virtual void addAction(Core::Command *action, const QString &group = QString()) = 0;
virtual void addMenu(Core::ActionContainer *menu, const QString &group = QString()) = 0;
virtual void addMenu(Core::ActionContainer *before, Core::ActionContainer *menu, const QString &group = QString()) = 0;
// clears this menu and submenus from all actions and submenus
// doesn't destroy the submenus and commands, just removes them from their parents
......
......@@ -62,6 +62,7 @@ public:
void appendGroup(const QString &id);
void addAction(Command *action, const QString &group = QString());
void addMenu(ActionContainer *menu, const QString &group = QString());
void addMenu(ActionContainer *before, ActionContainer *menu, const QString &group = QString());
virtual void clear();
int id() const;
......
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