Navigation Menu

Skip to content

Commit

Permalink
Disable "Change data source..." action if layer is editable
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Nov 8, 2018
1 parent 85f8ba3 commit c74ce88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/app/qgsapplayertreeviewmenuprovider.cpp
Expand Up @@ -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 )
Expand Down
Binary file modified tests/testdata/projects/bad_layers_test.gpkg
Binary file not shown.

0 comments on commit c74ce88

Please sign in to comment.