Skip to content

Commit

Permalink
Merge pull request #8521 from chau-intl/master
Browse files Browse the repository at this point in the history
Hide newly added layer(s) when in group. Fixes #19174
  • Loading branch information
luipir committed Nov 22, 2018
2 parents 5a8c9bf + 3ec853f commit a14f5e4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -4956,6 +4956,7 @@ void QgisApp::askUserForGDALSublayers( QgsRasterLayer *layer )

QgsLayerTreeGroup *group = nullptr;
bool addToGroup = settings.value( QStringLiteral( "/qgis/openSublayersInGroup" ), true ).toBool();
bool newLayersVisible = settings.value( QStringLiteral( "/qgis/new_layers_visible" ), true ).toBool();
if ( addToGroup )
{
group = QgsProject::instance()->layerTreeRoot()->insertGroup( 0, layer->name() );
Expand Down Expand Up @@ -4989,6 +4990,10 @@ void QgisApp::askUserForGDALSublayers( QgsRasterLayer *layer )
}
}
}

// Respect if user don't want the new group of layers visible.
if ( addToGroup && ! newLayersVisible )
group->setItemVisibilityCheckedRecursive( newLayersVisible );
}
}

Expand Down Expand Up @@ -5153,6 +5158,7 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
{
QgsSettings settings;
bool addToGroup = settings.value( QStringLiteral( "/qgis/openSublayersInGroup" ), true ).toBool();
bool newLayersVisible = settings.value( QStringLiteral( "/qgis/new_layers_visible" ), true ).toBool();
QgsLayerTreeGroup *group = nullptr;
if ( addToGroup )
group = QgsProject::instance()->layerTreeRoot()->insertGroup( 0, name );
Expand All @@ -5166,6 +5172,10 @@ void QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
if ( addToGroup )
group->addLayer( l );
}

// Respect if user don't want the new group of layers visible.
if ( addToGroup && ! newLayersVisible )
group->setItemVisibilityCheckedRecursive( newLayersVisible );
}
}

Expand Down

0 comments on commit a14f5e4

Please sign in to comment.