Created by: portnov
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
- Original solution: copy the preset from sverchok directory to user's datafiles directory only at first sverchok startup, when there is no file in datafiles. -
❌ Rejected: the file will not be updated when we add a new node in Sverchok, or rearrange the default menu. - Add a possibility to apply the selected menu preset automatically, at each blender startup. If enabled, at startup, copy the selected preset file from sverchok directory to user's datafiles. —
❌ Rejected: there is no sense in havingindex.yaml
in user's datafiles, if that file is never actually used, as it is overwritten at each blender startup. - ...If enabled, overwrite user's
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).
- Sub-option: preserve previous version of user's
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.
- Options 1 - 3 were designed having in mind the problem that we can not refer to preferences at the moment when we are loading the menu. But, if we need an option to enable or disable menu file overwriting, then we will have to solve that problem somehow. But, once it is solved, we can look into preferences and use menu preset file name from there. So: If the option is enabled, then do not copy anything, just use menu preset file from sverchok directory. If it is disabled, then we copy the preset file once at first Sverchok startup, and when the user explicitly presses the button. This means that if the option is disabled, the user takes responsibility of updating his
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:
-
Code changes complete. -
Code documentation complete. -
Documentation for users complete (or not required, if user never sees these changes). -
Manual testing done. -
Unit-tests implemented. -
Ready for merge.