Skip to content
Permalink
Browse files

When a layer's data source is broken, show "Repair Data Source"

instead of "Change Data Source" in its right click menu

Also show a warning icon for this action. It's a bit more explicit
and clear that the layer is broken and that picking that action is how to fix it.
  • Loading branch information
nyalldawson committed Aug 30, 2020
1 parent f46e58a commit 71d0948c448211275db258561766a99b16ff4db1
Showing with 5 additions and 1 deletion.
  1. +2 −0 src/app/qgisapp.cpp
  2. +3 −1 src/app/qgsapplayertreeviewmenuprovider.cpp
@@ -8109,6 +8109,8 @@ void QgisApp::changeDataSource( QgsMapLayer *layer )
QgsMapLayerType layerType( layer->type() );

QgsDataSourceSelectDialog dlg( mBrowserModel, true, layerType );
if ( !layer->isValid() )
dlg.setWindowTitle( tr( "Repair Data Source" ) );

const QVariantMap sourceParts = QgsProviderRegistry::instance()->decodeUri( layer->providerType(), layer->publicSource() );
QString source = layer->publicSource();
@@ -274,7 +274,9 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
if ( vlayer || rlayer )
{

QAction *a = new QAction( tr( "Change Data Source…" ), menu );
QAction *a = new QAction( layer->isValid() ? tr( "Change Data Source…" ) : tr( "Repair Data Source…" ), menu );
if ( !layer->isValid() )
a->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mIconWarning.svg" ) ) );
// Disable when layer is editable
if ( layer->isEditable() )
{

0 comments on commit 71d0948

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