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
[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.
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 theAdd 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.
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"
The text was updated successfully, but these errors were encountered: