Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight colors are now applied to specific layers or groups [fixes #2] #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Alex-Kent
Copy link

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 the LayerColorPlugin instance rather than to the layer_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's highlight_color custom property, see lines 317-322.

Comments

In the paint method, a call to index.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 the QgsMapLayer's name() method. One instance where this is the case is when Show Feature Count has been enabled for a layer.

Fixes #2

(The color stored in the layer/group's highlight_color custom property is now always used; previously color was tied to the displayed layer/group name)
@Alex-Kent
Copy link
Author

I coded a fix for the QGIS bug mentioned above (qgis/QGIS#60884); the pull request (qgis/QGIS#60897) is currently pended approval/merge.

With the patched version of QGIS this plugin's behavior for Duplicate Layer is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Colors are tied to the displayed layer/group labels, not to the individual layers/groups [with fix]
1 participant