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

[forms] Allow users to copy and paste form widget configurations from one field to another #46

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

gacarrillor
Copy link
Owner

@gacarrillor gacarrillor commented Nov 9, 2024

When configuring forms (e.g., using the Drag and Drop Designer) in layers with multiple fields, chances are we want to set similar or even the same configurations for a number of them. This process is currently manual, which ends up being a bit tedious and error prone.

This PR adds a handy context menu (in the Vector properties dialog, Attributes Form tab, Available Widgets tree, Fields category, :) ), allowing users to copy widget configurations between fields, and thus, saving time and making sure of not missing a particular setting by mistake.

image

Implementation details:

  • Copy&paste of widget configuration can be done between fields of the same layer, between fields from different layers in the QGIS project, or between fields from layers in different QGIS instances.
  • Pasted widget configuration overwrites the target one, but is not applied automatically, so that users can see the pasted configuration and possibly tune it and apply it or avoid saving it by cancelling the dialog or just selecting another field.
  • We avoid copying aliases and comments. The target field ones are respected.
  • A widget configuration can be copied and pasted on the very same field, thus adding support for keeping a widget config in the clipboard, making and testing changes and eventually reverting them by pasting the clipboard content in the same field.
  • We only paste "editor widget configs" when the target field supports the source editor widget type. Otherwise, we leave the target editor widget type and config intact, while showing a warning message (in dialog's message bar) explaining why the config could not be pasted.
  • Target provider constraints are kept, we only paste constraints with layer origin.

Fix 58971

Funded by (?)

@gacarrillor
Copy link
Owner Author

gacarrillor commented Nov 9, 2024

@3nids, before showing this to the world, could you please have a look at this PR?

Do we need QGIS_PROTECT_QOBJECT_THREAD_ACCESS in both copy and paste slots?

Note: I'll still tweak pasting constraints, since the use case of pasting an unset constraint on an already set one is currently missing. Done.

Copy link

github-actions bot commented Nov 9, 2024

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 0a63c26)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 0a63c26)

@3nids
Copy link

3nids commented Nov 11, 2024

Looking good!

@gacarrillor gacarrillor force-pushed the copy_paste_form_configuration branch from 74fb263 to 90a575d Compare November 25, 2024 16:20
@gacarrillor gacarrillor force-pushed the copy_paste_form_configuration branch from 90a575d to ff5d38d Compare December 20, 2024 22:05
…y and paste configuration actions: copy form config to clipboard and paste form config from clipboard (partial)
…a forceWidgetRefresh param and passing it as true when pasting; note we've respected the previous behavior (i.e., other calls still don't force a refresh) because it seems to be handy to switch between editor widget types (via GUI) without losing the config
… layout; since we only update GUI widgets (and don't automatically store pasted settings into tree item data nor in the field settings themselves), we've added handy methods to edit them
…traints can be both added and removed from the target field
…d by the target field, let users know (via message bar) why the config was not pasted
…lipboard and paste it in the very same field (could be useful as a undo operation after testing intermmediate changes)
@gacarrillor gacarrillor force-pushed the copy_paste_form_configuration branch from 61f1623 to af10cd3 Compare January 8, 2025 17:44
@gacarrillor gacarrillor closed this Jan 8, 2025
@gacarrillor gacarrillor reopened this Jan 8, 2025
@gacarrillor
Copy link
Owner Author

@3nids, do you know if we should add \since QGIS 3.42 to methods that are public with respect to their class but are not part of the public API (i.e., marked as SIP_NO_FILE)?

@3nids
Copy link

3nids commented Jan 9, 2025

no only to the class

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.

2 participants