mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
show "show more" item only when it is required (if there are more than 5
hidden items in the list)
This commit is contained in:
parent
602011a129
commit
7485602555
@ -177,6 +177,7 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe
|
||||
QMenu *hiddenMenu = new QMenu( tr( "Hidden Items" ), menu );
|
||||
int count = 0;
|
||||
const QStringList hiddenPathList = settings.value( QStringLiteral( "/browser/hiddenPaths" ) ).toStringList();
|
||||
static int MAX_HIDDEN_ENTRIES = 5;
|
||||
for ( const QString &path : hiddenPathList )
|
||||
{
|
||||
QAction *action = new QAction( QDir::toNativeSeparators( path ), hiddenMenu );
|
||||
@ -202,17 +203,23 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe
|
||||
} );
|
||||
hiddenMenu->addAction( action );
|
||||
count += 1;
|
||||
if ( count == 5 )
|
||||
if ( count == MAX_HIDDEN_ENTRIES )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
QAction *moreAction = new QAction( tr( "Show More…" ), hiddenMenu );
|
||||
connect( moreAction, &QAction::triggered, this, [ = ]
|
||||
|
||||
if ( hiddenPathList.size() > MAX_HIDDEN_ENTRIES )
|
||||
{
|
||||
QgisApp::instance()->showOptionsDialog( QgisApp::instance(), QStringLiteral( "mOptionsPageDataSources" ) );
|
||||
} );
|
||||
hiddenMenu->addAction( moreAction );
|
||||
hiddenMenu->addSeparator();
|
||||
|
||||
QAction *moreAction = new QAction( tr( "Show More…" ), hiddenMenu );
|
||||
connect( moreAction, &QAction::triggered, this, [ = ]
|
||||
{
|
||||
QgisApp::instance()->showOptionsDialog( QgisApp::instance(), QStringLiteral( "mOptionsPageDataSources" ) );
|
||||
} );
|
||||
hiddenMenu->addAction( moreAction );
|
||||
}
|
||||
if ( count > 0 )
|
||||
{
|
||||
menu->addMenu( hiddenMenu );
|
||||
|
Loading…
x
Reference in New Issue
Block a user