Skip to content
Permalink
Browse files

Merge pull request #8603 from chau-intl/release-3_4

[backport] Hide newly added layer(s) when in group. Fixes #19174
  • Loading branch information
luipir committed Dec 4, 2018
2 parents 1f97c17 + 651b656 commit a7ab47dd1d8fa26994f79674f3c2c45156da1c2c
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/app/qgisapp.cpp
@@ -4934,6 +4934,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() );
@@ -4967,6 +4968,10 @@ void QgisApp::askUserForGDALSublayers( QgsRasterLayer *layer )
}
}
}

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

@@ -5131,6 +5136,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 );
@@ -5144,6 +5150,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 );
}
}

0 comments on commit a7ab47d

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