Israel
Joined: Dec 24, 2023
Post Count: 10
Status:
Offline
How to save a user's (plugin-related) preferences?
Hey,
I was wondering if there was some mechanism with which I can persistently save a few settings the user can modify within my plugin. I've seen the UserPreferences class but it has setters/getters only for the specific options SH3D supports.
Is there some generic tags, key-value-pairs or anything that a plugin can set that will be saved as a part of the SH3D project file?
Israel
Joined: Dec 24, 2023
Post Count: 10
Status:
Offline
Re: How to save a user's (plugin-related) preferences?
Thanks, I believe you're referring to getProperty()/getNumericProperty()/setProperty()?
They seem to do the job, assuming I save the project file but setting a property doesn't seem to mark the project as modified so the user will be alerted that they need to save it. Is the plugin expected to call setModified() when a property's value changes?
France
Joined: Nov 7, 2005
Post Count: 9361
Status:
Offline
Re: How to save a user's (plugin-related) preferences?
Some properties are not so important to save like window size after resizing it. Some other properties should be saved and in that case, you should call setModified method. Prefer to use properties with a unique prefix to avoid any clash with future ones or properties managed by other plug-ins.
Note that these home properties are saved for a project, not for all projects like you seemed to want by speaking about "preferences". As you noticed, there are no setProperty / getProperty in UserPreferences class at the moment, but can save additional data at the same place as where preferences.xm file is saved if needed.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer