Disable "Change data source..." action if layer is editable

This commit is contained in:
Alessandro Pasotti 2018-11-08 09:22:33 +01:00
parent 85f8ba359f
commit c74ce886dc
2 changed files with 12 additions and 4 deletions

View File

@ -200,15 +200,23 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
menu->addSeparator();
// change data source is only supported for vectors and rasters
if ( vlayer || rlayer )
if ( ( vlayer || rlayer ) )
{
QAction *a = new QAction( tr( "Change data source…" ), menu );
connect( a, &QAction::triggered, [ = ]
if ( layer->isEditable() )
{
QgisApp::instance()->changeDataSource( layer );
} );
a->setEnabled( false );
}
else
{
connect( a, &QAction::triggered, [ = ]
{
QgisApp::instance()->changeDataSource( layer );
} );
}
menu->addAction( a );
// Disable when layer is editable
}
if ( vlayer )

Binary file not shown.