qgis / QGIS-Enhancement-Proposals

QEP's (QGIS Enhancement Proposals) are used in the process of creating and discussing new enhancements for QGIS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Layout Legends - Rework handling of initial layer set and synchronization

nyalldawson opened this issue · comments

QGIS Enhancement: Layout Legends - Rework handling of initial layer set and synchronization

Date 2022/05/30

Author Nyall Dawson (@nyalldawson)

Contact nyall dot dawson at gmail dot com

maintainer @nyalldawson

Version QGIS 3.X

Summary

The current QGIS logic for handling the initial set of layers visible in a legend is to always
place ALL layers from the project into the legend. This is a frustrating default for users of
complex projects, which may potentially contain hundreds of layers, resulting in a huge legend
which the user then needs to do a lot of manual work to clean up.

This proposal describes a rework of this logic, to make the legend item creation more user
friendly and flexible, and to better handle legend creation in complex/large projects.

Proposed Changes to Legend Sync Behaviour

Currently, QGIS offers a "auto sync" checkbox for layout legends (which is checked by default). When
checked, this option means that any layers added to the project will immediately be added to the legend,
and any changes to layers (such as renaming the layer in the project layer tree) will immediately
propagate this change to the layout legend too.

image

This "auto sync" option will be reworked to instead show users a drop-down menu of choices for
synchronization behaviour. The available options will be:

  1. Synchronize to All Project Layers
  2. Synchronize to Visible Layers
  3. Manual Layer Selection

Synchronize to All Project Layers

This option matches the current behaviour of the "Auto sync" checkbox. If selected, then
all new layers added to the project will appear immediately in the legend and any
changes made to these layers will immediately be applied to the legend.

Synchronize to Visible Layers

This option will consider which layers are currently visible in the map linked to the
legend item. When selected, then any changes to the set of layers visible in the legend
will cause the legend layers to be matched to this set of visible layers. Note that this
option differs from the existing "Only show items in the linked map" option because the
"Synchronize to Visible Layers" option does not consider the linked map extent at all -
if a layer is checked and visible for the map, then it will be shown in the legend
regardless of whether or not all features in the layer fall outside the visible map
extent.

Like the "Synchronize to Visible Layers" option, any changes made to the names or
other legend related settings in the main project layer tree will automatically
be propagated to the layout legend.

Manual Layer Selection

All content for the legend is controlled manually, and no auto-synchronization
will apply. This is the same behaviour as currently happens in QGIS if the "auto update"
option is unchecked.

Proposed Changes to Legend "Update All" button

In current QGIS versions accompanying the existing "Auto update" checkbox is a button for "Update All".
(This button is DISABLED when the auto-update checkbox is checked, so it can only be clicked
when a user is manually controlling the legend content). When clicked, the current legend item
customisations are discarded and the legend is reset to contain ALL project layers with their
project layer tree naming.

image

This button will be reworked, and be renamed to "Reset layers". Clicking it will show a drop-down
menu choice with:

  1. Reset to All Project Layers
  2. Reset to Visible Layers

Clicking Reset to All Project Layers will discard all the existing legend content and
repopulate the legend with every layer from the project. Clicking Reset to Visible Layers
will discard all existing legend content and repopulate only from visible layers. In
either case the synchronize option for the legend will remain at "Manual Layer Selection".

The intended use case for this button is for a user who is manually customising legend
content but needs to do a one-off reset to the project/visible layers state.

(The "reset layers" button will only be enabled when the legend synchronization mdode
is set to "Manual Layer Selection".)

New setting for Default Legend Mode

To accompany the changes, a new global setting in the Settings - Layout pane will be
added to allow users to set the default initial synchronization mode for newly created
legends. The options will match those from the synchronization modes choices.

E.g. if the global option is set to "Include visible layers", then a newly created
legend will be set to the "Synchronize to Visible Layers" option and will contain
only layers currently visible in the project. If the global option is set to "manual"
then newly created legends will initially be empty and users must manually populate
them.

Optionally, we could investigate whether the "Include visible layers" option is a better
default choice for new installs vs always including all project layers (as we currently
do).

Backwards Compatibility

none

excellent idea.
I favor a default of "include visible layers" as the default for new installations, as well being the initial default for when this is first implemented and no previous default is available.

Great idea, sounds almost exactly how I'd like it to work.
It would also be great if the dialogue to add layers to the legend defaulted to visible layers only. I can't think of many cases of wanting to add things to the legend that are not in the map.

I'd also love a way to customise the legend entry for a layer that would be attached to the layer - so appear in all layouts, and a way for an imagery layer to appear in the legend just as the attribution text instead of bands, but I think those are separate feature requests.

Great proposal.
I also think include visible layers as default is a good choice for new users and fresh install.

@nyalldawson : two typos in the QEP.

Paragraph "Synchronize to Visible Layers" : Like the "Synchronize to Visible Layers" option ==> Like the "Synchronize to All Layers" option
Paragraph "Proposed Changes to Legend "Update All" button" : The "reset layers" button will only be enabled when the legend synchronization mdode ==> mode

commented

I'm not sure about using 'visible layers', users may expect to only have layers visible within the extent of the map. Wouldn't 'Active Layers' make more sense from a terminology standpoint?

it's look useful but peharps simpliest with several "reset butons" instead of a question.

I would like to see an ‘update symbology’ button that preserves the text customization.

I'm not sure about using 'visible layers', users may expect to only have layers visible within the extent of the map. Wouldn't 'Active Layers' make more sense from a terminology standpoint?

I agree, I think 'active layers' is a better phrase. What do others think?

I also think setting the default as 'Visible layers' is a good idea.

Is it also possible to have the check-box for 'Only show items inside current atlas feature' hidden, unless the user has activated the atlas option? For those new users, atlas features is something they may not know about, so it is an additional box they don't need. I am thinking to try and keep things as simple as possible!

commented

This would be of great help! Defaulting to visible layers is probably the most logical one indeed