Skip to content

Commit 2f70dd0

Browse files
committed
[layouts] sort panels and toolbars sub-menus
1 parent 007009f commit 2f70dd0

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/app/layout/qgslayoutdesignerdialog.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ void QgsAppLayoutDesignerInterface::close()
131131
}
132132

133133

134+
static bool cmpByText_( QAction *a, QAction *b )
135+
{
136+
return QString::localeAwareCompare( a->text(), b->text() ) < 0;
137+
}
138+
139+
134140
QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFlags flags )
135141
: QMainWindow( parent, flags )
136142
, mInterface( new QgsAppLayoutDesignerInterface( this ) )
@@ -729,6 +735,14 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
729735
mLayoutsMenu->setObjectName( QStringLiteral( "mLayoutsMenu" ) );
730736
connect( mLayoutsMenu, &QMenu::aboutToShow, this, &QgsLayoutDesignerDialog::populateLayoutsMenu );
731737

738+
QList<QAction *> actions = mPanelsMenu->actions();
739+
std::sort( actions.begin(), actions.end(), cmpByText_ );
740+
mPanelsMenu->insertActions( nullptr, actions );
741+
742+
actions = mToolbarMenu->actions();
743+
std::sort( actions.begin(), actions.end(), cmpByText_ );
744+
mToolbarMenu->insertActions( nullptr, actions );
745+
732746
restoreWindowState();
733747

734748
//listen out to status bar updates from the view
@@ -740,11 +754,6 @@ QgsAppLayoutDesignerInterface *QgsLayoutDesignerDialog::iface()
740754
return mInterface;
741755
}
742756

743-
static bool cmpByText_( QAction *a, QAction *b )
744-
{
745-
return QString::localeAwareCompare( a->text(), b->text() ) < 0;
746-
}
747-
748757
QMenu *QgsLayoutDesignerDialog::createPopupMenu()
749758
{
750759
QMenu *menu = QMainWindow::createPopupMenu();

0 commit comments

Comments
 (0)