Skip to content
Permalink
Browse files
[browser] Add a menu entry to the context menu for directory items
to allow users to explicit control whether a directory is
automatically monitored for changes.
  • Loading branch information
nyalldawson committed May 31, 2021
1 parent af1900f commit 75838d3d89c74dc1d99c3e5edc9b8e288769df04
Showing with 24 additions and 2 deletions.
  1. +23 −2 src/app/browser/qgsinbuiltdataitemproviders.cpp
  2. +1 −0 src/app/browser/qgsinbuiltdataitemproviders.h
@@ -263,16 +263,29 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe
menu->addAction( actionClearIconColor );
}

QAction *fastScanAction = new QAction( tr( "Fast Scan this Directory" ), menu );
QMenu *scanningMenu = new QMenu( tr( "Scanning" ), menu );

QAction *monitorAction = new QAction( tr( "Monitor for Changes" ), scanningMenu );
connect( monitorAction, &QAction::triggered, this, [ = ]
{
toggleMonitor( directoryItem );
} );
monitorAction->setCheckable( true );
monitorAction->setChecked( directoryItem->isMonitored() );
scanningMenu->addAction( monitorAction );

QAction *fastScanAction = new QAction( tr( "Fast Scan this Directory" ), scanningMenu );
connect( fastScanAction, &QAction::triggered, this, [ = ]
{
toggleFastScan( directoryItem );
} );
menu->addAction( fastScanAction );
fastScanAction->setCheckable( true );
fastScanAction->setChecked( settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
QStringList() ).toStringList().contains( item->path() ) );

scanningMenu->addAction( fastScanAction );
menu->addMenu( scanningMenu );

menu->addSeparator();

QAction *openFolder = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "mIconFolder.svg" ) ), tr( "Open Directory…" ), menu );
@@ -382,6 +395,14 @@ void QgsAppDirectoryItemGuiProvider::toggleFastScan( QgsDirectoryItem *item )
settings.setValue( QStringLiteral( "qgis/scanItemsFastScanUris" ), fastScanDirs );
}

void QgsAppDirectoryItemGuiProvider::toggleMonitor( QgsDirectoryItem *item )
{
if ( item->isMonitored() )
item->setMonitoring( Qgis::BrowserDirectoryMonitoring::NeverMonitor );
else
item->setMonitoring( Qgis::BrowserDirectoryMonitoring::AlwaysMonitor );
}

void QgsAppDirectoryItemGuiProvider::showProperties( QgsDirectoryItem *item, QgsDataItemGuiContext context )
{
if ( ! item )
@@ -50,6 +50,7 @@ class QgsAppDirectoryItemGuiProvider : public QObject, public QgsDataItemGuiProv
void clearDirectoryColor( QgsDirectoryItem *item );
void hideDirectory( QgsDirectoryItem *item );
void toggleFastScan( QgsDirectoryItem *item );
void toggleMonitor( QgsDirectoryItem *item );
void showProperties( QgsDirectoryItem *item, QgsDataItemGuiContext context );
};

0 comments on commit 75838d3

Please sign in to comment.