Commit 47fedc3d authored by hjk's avatar hjk Committed by hjk

debugger: sort entries in Windows->Views the same way as in the dock context menus

Task-number: QTCREATORBUG-6179
Change-Id: I1bc02ebce6de7ff5c12d7baf7c585a414f3972d5
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 3b019fe2
......@@ -136,6 +136,7 @@ public:
DebuggerLanguages m_engineDebugLanguages;
ActionContainer *m_viewsMenu;
QList<Command *> m_menuCommandsToAdd;
Project *m_previousProject;
Target *m_previousTarget;
......@@ -321,7 +322,8 @@ void DebuggerMainWindowPrivate::createViewsMenuItems()
Core::Id("Debugger.Views.OpenMemoryEditor"),
debugcontext);
cmd->setAttribute(Command::CA_Hide);
m_viewsMenu->addAction(cmd);
m_viewsMenu->addAction(cmd, Core::Constants::G_DEFAULT_THREE);
cmd = am->registerAction(q->menuSeparator1(),
Core::Id("Debugger.Views.Separator1"), debugcontext);
cmd->setAttribute(Command::CA_Hide);
......@@ -429,7 +431,7 @@ QDockWidget *DebuggerMainWindow::createDockWidget(const DebuggerLanguage &langua
Command *cmd = am->registerAction(toggleViewAction,
Core::Id(QLatin1String("Debugger.") + widget->objectName()), globalContext);
cmd->setAttribute(Command::CA_Hide);
d->m_viewsMenu->addAction(cmd);
d->m_menuCommandsToAdd.append(cmd);
dockWidget->installEventFilter(&d->m_resizeEventFilter);
......@@ -443,6 +445,19 @@ QDockWidget *DebuggerMainWindow::createDockWidget(const DebuggerLanguage &langua
return dockWidget;
}
static bool sortCommands(Command *cmd1, Command *cmd2)
{
return cmd1->action()->text() < cmd2->action()->text();
}
void DebuggerMainWindow::addStagedMenuEntries()
{
qSort(d->m_menuCommandsToAdd.begin(), d->m_menuCommandsToAdd.end(), &sortCommands);
foreach (Command *cmd, d->m_menuCommandsToAdd)
d->m_viewsMenu->addAction(cmd);
d->m_menuCommandsToAdd.clear();
}
QWidget *DebuggerMainWindow::createContents(IMode *mode)
{
ICore *core = ICore::instance();
......
......@@ -73,6 +73,7 @@ public:
// Dockwidgets are registered to the main window.
QDockWidget *createDockWidget(const DebuggerLanguage &language, QWidget *widget);
void addStagedMenuEntries();
QWidget *createContents(Core::IMode *mode);
QMenu *createPopupMenu();
......
......@@ -3025,6 +3025,8 @@ void DebuggerPluginPrivate::extensionsInitialized()
dock = m_mainWindow->createDockWidget(CppLanguage, localsAndWatchers);
dock->setProperty(DOCKWIDGET_DEFAULT_AREA, Qt::RightDockWidgetArea);
m_mainWindow->addStagedMenuEntries();
// Do not fail to load the whole plugin if something goes wrong here.
QString errorMessage;
if (!parseArguments(m_arguments, &m_cmdLineEnabledEngines, &errorMessage)) {
......
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