You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the color used for a layer/group layer is determined by its name as displayed in the layers tree. If a layer is renamed (e.g. by the user or by selecting "Show Feature Count") then the custom background color is no longer shown. In addition, multiple layers with the same name cannot currently have different colors assigned.
Proposed fix
If the color to be used is retrieved from the layer's highlight_color custom property (instead of from the layer_colors array with the displayed name as the key) then the color will persist if the layer is renamed.
I have written and tested code to do this (I'll submit a pull request shortly [edit: It's linked below]).
Comments
An additional benefit to my fix is that layers with the same displayed name can be assigned different colors.
One issue is that the color assigned to a layer is no longer automatically applied to all layers with the same displayed name. This could be remedied by adding options to apply the selected groups/layers color to some or all layers/groups that have the same name as the selected layers/groups. [This is something that I'm willing to code.] I can go into detail on this separately.
Alternatively [and if implemented I think that it should be a user-selectable option] the current behavior could be emulated using the actual layer name (as opposed to the displayed name which may e.g. have a feature count appended) as the array key; this has its own set of issues that I have not fully explored (e.g. if a layer is manually renamed then the extant color should be carried over [but what if the new name already has a color assigned?]).
The selected color will be carried over if a layer/group is copied and pasted. A layer's color is not preserved though if "Duplicate Layer" is used; this appears to be due to a bug in QGIS (I've opened a bug report, see "Duplicate Layer" does not copy some custom properties qgis/QGIS#60884).
The text was updated successfully, but these errors were encountered:
Currently the color used for a layer/group layer is determined by its name as displayed in the layers tree. If a layer is renamed (e.g. by the user or by selecting "Show Feature Count") then the custom background color is no longer shown. In addition, multiple layers with the same name cannot currently have different colors assigned.
Proposed fix
If the color to be used is retrieved from the layer's
highlight_color
custom property (instead of from thelayer_colors
array with the displayed name as the key) then the color will persist if the layer is renamed.I have written and tested code to do this (
I'll submit a pull request shortly[edit: It's linked below]).Comments
An additional benefit to my fix is that layers with the same displayed name can be assigned different colors.
One issue is that the color assigned to a layer is no longer automatically applied to all layers with the same displayed name. This could be remedied by adding options to apply the selected groups/layers color to some or all layers/groups that have the same name as the selected layers/groups. [This is something that I'm willing to code.] I can go into detail on this separately.
Alternatively [and if implemented I think that it should be a user-selectable option] the current behavior could be emulated using the actual layer name (as opposed to the displayed name which may e.g. have a feature count appended) as the array key; this has its own set of issues that I have not fully explored (e.g. if a layer is manually renamed then the extant color should be carried over [but what if the new name already has a color assigned?]).
The selected color will be carried over if a layer/group is copied and pasted. A layer's color is not preserved though if "Duplicate Layer" is used; this appears to be due to a bug in QGIS (I've opened a bug report, see "Duplicate Layer" does not copy some custom properties qgis/QGIS#60884).
The text was updated successfully, but these errors were encountered: