File tree 3 files changed +41
-0
lines changed
3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -7746,7 +7746,33 @@ void QgisApp::legendLayerStretchUsingCurrentExtent()
7746
7746
}
7747
7747
}
7748
7748
7749
+ void QgisApp::applyStyleToGroup ()
7750
+ {
7751
+ if ( !mLayerTreeView )
7752
+ return ;
7749
7753
7754
+ Q_FOREACH ( QgsLayerTreeNode* node, mLayerTreeView ->selectedNodes () )
7755
+ {
7756
+ if ( QgsLayerTree::isGroup ( node ) )
7757
+ {
7758
+ Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, QgsLayerTree::toGroup ( node )->findLayers () )
7759
+ {
7760
+ if ( nodeLayer->layer () )
7761
+ {
7762
+ pasteStyle ( nodeLayer->layer () );
7763
+ }
7764
+ }
7765
+ }
7766
+ else if ( QgsLayerTree::isLayer ( node ) )
7767
+ {
7768
+ QgsLayerTreeLayer* nodeLayer = QgsLayerTree::toLayer ( node );
7769
+ if ( nodeLayer->layer () )
7770
+ {
7771
+ pasteStyle ( nodeLayer->layer () );
7772
+ }
7773
+ }
7774
+ }
7775
+ }
7750
7776
7751
7777
void QgisApp::legendGroupSetCRS ()
7752
7778
{
Original file line number Diff line number Diff line change @@ -748,6 +748,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
748
748
Only workds on raster layers*/
749
749
void legendLayerStretchUsingCurrentExtent ();
750
750
751
+ /* * Apply the same style to selected layers or to current legend group*/
752
+ void applyStyleToGroup ();
753
+
751
754
/* * Set the CRS of the current legend group*/
752
755
void legendGroupSetCRS ();
753
756
Original file line number Diff line number Diff line change @@ -66,6 +66,11 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
66
66
if ( mView ->selectedNodes ( true ).count () >= 2 )
67
67
menu->addAction ( actions->actionGroupSelected ( menu ) );
68
68
69
+ if ( QgisApp::instance ()->clipboard ()->hasFormat ( QGSCLIPBOARD_STYLE_MIME ) )
70
+ {
71
+ menu->addAction ( tr ( " Paste Style" ), QgisApp::instance (), SLOT ( applyStyleToGroup () ) );
72
+ }
73
+
69
74
menu->addAction ( tr ( " Save As Layer Definition File..." ), QgisApp::instance (), SLOT ( saveAsLayerDefinition () ) );
70
75
71
76
menu->addAction ( actions->actionAddGroup ( menu ) );
@@ -121,6 +126,13 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
121
126
122
127
menu->addMenu ( menuStyleManager );
123
128
}
129
+ else
130
+ {
131
+ if ( QgisApp::instance ()->clipboard ()->hasFormat ( QGSCLIPBOARD_STYLE_MIME ) )
132
+ {
133
+ menu->addAction ( tr ( " Paste Style" ), QgisApp::instance (), SLOT ( applyStyleToGroup () ) );
134
+ }
135
+ }
124
136
125
137
menu->addSeparator ();
126
138
You can’t perform that action at this time.
0 commit comments