@@ -264,44 +264,44 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
264
264
menu->addAction ( QgsApplication::getThemeIcon ( " /mActionHideAllLayers.png" ), tr ( " &Hide All Items" ),
265
265
symbolNode, SLOT ( uncheckAllItems () ) );
266
266
menu->addSeparator ();
267
+ }
267
268
268
- if ( symbolNode->symbol () )
269
+ if ( symbolNode->symbol () )
270
+ {
271
+ QgsColorWheel* colorWheel = new QgsColorWheel ( menu );
272
+ colorWheel->setColor ( symbolNode->symbol ()->color () );
273
+ QgsColorWidgetAction* colorAction = new QgsColorWidgetAction ( colorWheel, menu, menu );
274
+ colorAction->setDismissOnColorSelection ( false );
275
+ connect ( colorAction, SIGNAL ( colorChanged ( const QColor& ) ), this , SLOT ( setSymbolLegendNodeColor ( const QColor& ) ) );
276
+ // store the layer id and rule key in action, so we can later retrieve the corresponding
277
+ // legend node, if it still exists
278
+ colorAction->setProperty ( " layerId" , symbolNode->layerNode ()->layerId () );
279
+ colorAction->setProperty ( " ruleKey" , symbolNode->data ( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString () );
280
+ menu->addAction ( colorAction );
281
+
282
+ // add recent colors action
283
+ QList<QgsRecentColorScheme *> recentSchemes;
284
+ QgsColorSchemeRegistry::instance ()->schemes ( recentSchemes );
285
+ if ( !recentSchemes.isEmpty () )
269
286
{
270
- QgsColorWheel* colorWheel = new QgsColorWheel ( menu );
271
- colorWheel->setColor ( symbolNode->symbol ()->color () );
272
- QgsColorWidgetAction* colorAction = new QgsColorWidgetAction ( colorWheel, menu, menu );
273
- colorAction->setDismissOnColorSelection ( false );
274
- connect ( colorAction, SIGNAL ( colorChanged ( const QColor& ) ), this , SLOT ( setSymbolLegendNodeColor ( const QColor& ) ) );
275
- // store the layer id and rule key in action, so we can later retrieve the corresponding
276
- // legend node, if it still exists
277
- colorAction->setProperty ( " layerId" , symbolNode->layerNode ()->layerId () );
278
- colorAction->setProperty ( " ruleKey" , symbolNode->data ( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString () );
279
- menu->addAction ( colorAction );
280
-
281
- // add recent colors action
282
- QList<QgsRecentColorScheme *> recentSchemes;
283
- QgsColorSchemeRegistry::instance ()->schemes ( recentSchemes );
284
- if ( !recentSchemes.isEmpty () )
285
- {
286
- QgsColorSwatchGridAction* recentColorAction = new QgsColorSwatchGridAction ( recentSchemes.at ( 0 ), menu, " symbology" , menu );
287
- recentColorAction->setProperty ( " layerId" , symbolNode->layerNode ()->layerId () );
288
- recentColorAction->setProperty ( " ruleKey" , symbolNode->data ( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString () );
289
- recentColorAction->setDismissOnColorSelection ( false );
290
- menu->addAction ( recentColorAction );
291
- connect ( recentColorAction, SIGNAL ( colorChanged ( const QColor& ) ), this , SLOT ( setSymbolLegendNodeColor ( const QColor& ) ) );
292
- }
293
-
294
- menu->addSeparator ();
287
+ QgsColorSwatchGridAction* recentColorAction = new QgsColorSwatchGridAction ( recentSchemes.at ( 0 ), menu, " symbology" , menu );
288
+ recentColorAction->setProperty ( " layerId" , symbolNode->layerNode ()->layerId () );
289
+ recentColorAction->setProperty ( " ruleKey" , symbolNode->data ( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString () );
290
+ recentColorAction->setDismissOnColorSelection ( false );
291
+ menu->addAction ( recentColorAction );
292
+ connect ( recentColorAction, SIGNAL ( colorChanged ( const QColor& ) ), this , SLOT ( setSymbolLegendNodeColor ( const QColor& ) ) );
295
293
}
296
294
297
- QAction* editSymbolAction = new QAction ( tr ( " Edit Symbol..." ), menu );
298
- // store the layer id and rule key in action, so we can later retrieve the corresponding
299
- // legend node, if it still exists
300
- editSymbolAction->setProperty ( " layerId" , symbolNode->layerNode ()->layerId () );
301
- editSymbolAction->setProperty ( " ruleKey" , symbolNode->data ( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString () );
302
- connect ( editSymbolAction, SIGNAL ( triggered () ), this , SLOT ( editSymbolLegendNodeSymbol () ) );
303
- menu->addAction ( editSymbolAction );
295
+ menu->addSeparator ();
304
296
}
297
+
298
+ QAction* editSymbolAction = new QAction ( tr ( " Edit Symbol..." ), menu );
299
+ // store the layer id and rule key in action, so we can later retrieve the corresponding
300
+ // legend node, if it still exists
301
+ editSymbolAction->setProperty ( " layerId" , symbolNode->layerNode ()->layerId () );
302
+ editSymbolAction->setProperty ( " ruleKey" , symbolNode->data ( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString () );
303
+ connect ( editSymbolAction, SIGNAL ( triggered () ), this , SLOT ( editSymbolLegendNodeSymbol () ) );
304
+ menu->addAction ( editSymbolAction );
305
305
}
306
306
}
307
307
0 commit comments