Skip to content

Commit

Permalink
[layouts] sort panels and toolbars sub-menus
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Feb 19, 2018
1 parent 007009f commit 2f70dd0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -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 ) )
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit 2f70dd0

Please sign in to comment.