mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
Merge pull request #2575 from slarosa/style_grp_layers
[FEATURE] allow applying the same style to selected layers or to legend group
This commit is contained in:
commit
2d9f36100e
@ -7746,7 +7746,33 @@ void QgisApp::legendLayerStretchUsingCurrentExtent()
|
||||
}
|
||||
}
|
||||
|
||||
void QgisApp::applyStyleToGroup()
|
||||
{
|
||||
if ( !mLayerTreeView )
|
||||
return;
|
||||
|
||||
Q_FOREACH ( QgsLayerTreeNode* node, mLayerTreeView->selectedNodes() )
|
||||
{
|
||||
if ( QgsLayerTree::isGroup( node ) )
|
||||
{
|
||||
Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, QgsLayerTree::toGroup( node )->findLayers() )
|
||||
{
|
||||
if ( nodeLayer->layer() )
|
||||
{
|
||||
pasteStyle( nodeLayer->layer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( QgsLayerTree::isLayer( node ) )
|
||||
{
|
||||
QgsLayerTreeLayer* nodeLayer = QgsLayerTree::toLayer( node );
|
||||
if ( nodeLayer->layer() )
|
||||
{
|
||||
pasteStyle( nodeLayer->layer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgisApp::legendGroupSetCRS()
|
||||
{
|
||||
|
@ -748,6 +748,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
Only workds on raster layers*/
|
||||
void legendLayerStretchUsingCurrentExtent();
|
||||
|
||||
/** Apply the same style to selected layers or to current legend group*/
|
||||
void applyStyleToGroup();
|
||||
|
||||
/** Set the CRS of the current legend group*/
|
||||
void legendGroupSetCRS();
|
||||
|
||||
|
@ -66,6 +66,11 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
|
||||
if ( mView->selectedNodes( true ).count() >= 2 )
|
||||
menu->addAction( actions->actionGroupSelected( menu ) );
|
||||
|
||||
if ( QgisApp::instance()->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
|
||||
{
|
||||
menu->addAction( tr( "Paste Style" ), QgisApp::instance(), SLOT( applyStyleToGroup() ) );
|
||||
}
|
||||
|
||||
menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) );
|
||||
|
||||
menu->addAction( actions->actionAddGroup( menu ) );
|
||||
@ -121,6 +126,13 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
|
||||
|
||||
menu->addMenu( menuStyleManager );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( QgisApp::instance()->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
|
||||
{
|
||||
menu->addAction( tr( "Paste Style" ), QgisApp::instance(), SLOT( applyStyleToGroup() ) );
|
||||
}
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user