From 2f70dd0a422fa21d4fb44ff89e284a44fa9cc0ca Mon Sep 17 00:00:00 2001 From: nirvn Date: Mon, 19 Feb 2018 16:19:14 +0700 Subject: [PATCH] [layouts] sort panels and toolbars sub-menus --- src/app/layout/qgslayoutdesignerdialog.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/layout/qgslayoutdesignerdialog.cpp b/src/app/layout/qgslayoutdesignerdialog.cpp index d659944903d..6b8b7b036ea 100644 --- a/src/app/layout/qgslayoutdesignerdialog.cpp +++ b/src/app/layout/qgslayoutdesignerdialog.cpp @@ -131,6 +131,12 @@ void QgsAppLayoutDesignerInterface::close() } +static bool cmpByText_( QAction *a, QAction *b ) +{ + return QString::localeAwareCompare( a->text(), b->text() ) < 0; +} + + QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFlags flags ) : QMainWindow( parent, flags ) , mInterface( new QgsAppLayoutDesignerInterface( this ) ) @@ -729,6 +735,14 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mLayoutsMenu->setObjectName( QStringLiteral( "mLayoutsMenu" ) ); connect( mLayoutsMenu, &QMenu::aboutToShow, this, &QgsLayoutDesignerDialog::populateLayoutsMenu ); + QList actions = mPanelsMenu->actions(); + std::sort( actions.begin(), actions.end(), cmpByText_ ); + mPanelsMenu->insertActions( nullptr, actions ); + + actions = mToolbarMenu->actions(); + std::sort( actions.begin(), actions.end(), cmpByText_ ); + mToolbarMenu->insertActions( nullptr, actions ); + restoreWindowState(); //listen out to status bar updates from the view @@ -740,11 +754,6 @@ QgsAppLayoutDesignerInterface *QgsLayoutDesignerDialog::iface() return mInterface; } -static bool cmpByText_( QAction *a, QAction *b ) -{ - return QString::localeAwareCompare( a->text(), b->text() ) < 0; -} - QMenu *QgsLayoutDesignerDialog::createPopupMenu() { QMenu *menu = QMainWindow::createPopupMenu();