QmlDesigner: Sort names of views in menu

Change-Id: I24f260ad74c0df5ccc979fa3c21c6edba8eff9fc
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Thomas Hartmann
2022-07-04 18:00:30 +02:00
parent 06be8a4325
commit e45ab20bef

View File

@@ -255,6 +255,8 @@ void DesignModeWidget::setup()
// First get all navigation views // First get all navigation views
QList<Core::INavigationWidgetFactory *> factories = Core::INavigationWidgetFactory::allNavigationFactories(); QList<Core::INavigationWidgetFactory *> factories = Core::INavigationWidgetFactory::allNavigationFactories();
QList<Core::Command*> viewCommands;
for (Core::INavigationWidgetFactory *factory : factories) { for (Core::INavigationWidgetFactory *factory : factories) {
Core::NavigationView navigationView; Core::NavigationView navigationView;
navigationView.widget = nullptr; navigationView.widget = nullptr;
@@ -304,7 +306,7 @@ void DesignModeWidget::setup()
actionToggle.withSuffix(uniqueId + "Widget"), actionToggle.withSuffix(uniqueId + "Widget"),
designContext); designContext);
command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_Hide);
mviews->addAction(command); viewCommands.append(command);
} }
} }
@@ -327,7 +329,7 @@ void DesignModeWidget::setup()
actionToggle.withSuffix(widgetInfo.uniqueId + "Widget"), actionToggle.withSuffix(widgetInfo.uniqueId + "Widget"),
designContext); designContext);
command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_Hide);
mviews->addAction(command); viewCommands.append(command);
} }
// Finally the output pane // Finally the output pane
@@ -347,12 +349,19 @@ void DesignModeWidget::setup()
actionToggle.withSuffix("OutputPaneWidget"), actionToggle.withSuffix("OutputPaneWidget"),
designContext); designContext);
command->setAttribute(Core::Command::CA_Hide); command->setAttribute(Core::Command::CA_Hide);
mviews->addAction(command); viewCommands.append(command);
connect(outputPanePlaceholder, &Core::OutputPanePlaceHolder::visibilityChangeRequested, connect(outputPanePlaceholder, &Core::OutputPanePlaceHolder::visibilityChangeRequested,
m_outputPaneDockWidget, &ADS::DockWidget::toggleView); m_outputPaneDockWidget, &ADS::DockWidget::toggleView);
} }
std::sort(viewCommands.begin(), viewCommands.end(), [](Core::Command *first, Core::Command *second){
return first->description() < second->description();
});
for (Core::Command *command : viewCommands)
mviews->addAction(command);
// Create toolbars // Create toolbars
auto toolBar = new QToolBar(); auto toolBar = new QToolBar();