[layouts] sort panels and toolbars sub-menus

This commit is contained in:
nirvn 2018-02-19 16:19:14 +07:00 committed by Mathieu Pellerin
parent 007009f9b8
commit 2f70dd0a42

View File

@ -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<QAction *> 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();