Menu presets: automatic application. #4856
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addressed problem description
This is a continuation of #4841.
When we add a node, or just rearrange menu presets for some reason, user's index.yaml in datafiles directory still has to be updated. Before current PR, user had to press "Set" in preferences manually after each sverchok update. This is not obvious at all.
Options which were considered
index.yaml
in user's datafiles, if that file is never actually used, as it is overwritten at each blender startup.index.yaml
only when the file in sverchok directory is newer than the one in datafiles. ❌ Rejected: not obvious for user, when his changes are overwritten, and there is no clear enough way to notify the user of such actions (message in the log will be most probably ignored).index.yaml
asindex.yaml.bak
. ❌ Rejected: there is no clear or obvious way for user to merge his version of menu with the one from sverchok preset. And again, no clear way for user to know when his changes were overwritten.index.yaml
. ✔️Solution description
Add a possibility to use the menu preset file from sverchok directory directly, ignoring the file in user's datafiles.
If the feature is not enabled, it means the user takes the responsibility on updating his index.yaml manually.
Technically, for this to work, I had to implement "lazy" initialization of "add node" menu, because in previous state, when I tried to call to preferences at the place where we located
index.yaml
, it appeared that preferences were not registered yet.Preflight checklist
Put an x letter in each brackets when you're done this item: