Skip to content
Permalink
Browse files

show "show more" item only when it is required (if there are more than 5

hidden items in the list)
  • Loading branch information
alexbruy committed Aug 19, 2020
1 parent 602011a commit 748560255571684ae8fac79352c47d044e9d5fca
Showing with 13 additions and 6 deletions.
  1. +13 −6 src/app/browser/qgsinbuiltdataitemproviders.cpp
@@ -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 );

0 comments on commit 7485602

Please sign in to comment.
You can’t perform that action at this time.