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

[feature] Allow users to save expression functions in QGIS project file (Request in QGIS) #9258

Closed
qgis-bot opened this issue Sep 13, 2024 · 0 comments · Fixed by #9293
Closed

Comments

@qgis-bot
Copy link
Collaborator

Request for documentation

From pull request qgis/QGIS#58354
Author: @gacarrillor
QGIS version: 3.40

[feature] Allow users to save expression functions in QGIS project file

PR Description:

Current situation:
In the expression builder dialog, Python functions can only be saved in the user profile directory. If a user wants to share expression functions with colleagues, he/she needs to share his/her expressions directory or individual .py files, which is inconvenient (without mentioning the installation of those shared files won't be trivial either).

This PR allows users to also store expression functions into the current QGIS project file, making it easier to share functions with other interested parties.

Some details about the implementation:

  • At most, one [Project Functions] item will be listed in the left-hand side list widget (Function Editor tab).

  • Users will be able to add and remove the aforementioned item.

  • If a [Project Functions] item already exists in the list, the corresponding option in the Add Function File dialog will be disabled.

  • Project gets dirty when expression functions are added to the project or when they are edited.

  • When opening the QGIS project, we check user preferences about loading project functions (Never|Ask|For this session only|Not during this session|Always) and load project functions if they're allowed.

  • Project functions are unloaded when a project is closed, and the user functions are reloaded to avoid any potential overwrite done by project functions activated by a regular user (i.e., a user that does not alter Project functions but that loads (enabling them) them when opening the project).

    Note: This behavior differs with respect to expression functions saved in the user profile (i.e., when a function file is removed, expression functions are not unloaded for the ongoing QGIS session). The rationale behind this is that user functions need more knowledge from the user (she/he needs to write them or at least deal with Python files to install them), whereas in the case of projects, any (non-python-expert) user could trigger an overwrite just by opening the project with functions and allowing them in the QGIS session.

image

image

Unit tests included.


Funded by the QGIS user group Switzerland.

Commits tagged with [need-docs] or [FEATURE]

"[feature] Allow to add/save/autosave/remove expression functions in a QGIS project"

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

Successfully merging a pull request may close this issue.

2 participants