Highlight colors are now applied to specific layers or groups [fixes #2] #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The color stored in the layer/group's
highlight_color
custom property is now always used for the layer/group's color; previously the color used was determined by displayed layer/group name.This code has has been well tested and only one non-critical issue was observed (likely a QGIS bug, see #2 and qgis/QGIS#60884 for details).
Key changes:
The
layer_colors
array is no longer needed and has been removed.At instantiation time, the
LayerColorDelegate
class constructor is passed a reference to theLayerColorPlugin
instance rather than to thelayer_colors
array as was done previously.The color to use for a particular layer or group is retrieved in the
paint
method from the layer/group'shighlight_color
custom property, see lines 317-322.Comments
In the
paint
method, a call toindex.data(Qt.DisplayRole)
(line 317 in the original code) returns the label as displayed in the layers tree. This is not always the same as the layer or group name that can be retrieved using theQgsMapLayer
'sname()
method. One instance where this is the case is when Show Feature Count has been enabled for a layer.Fixes #2