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?
Thanks in advance!
How to save a user's (plugin-related) preferences?
This topic has been viewed 3804 times and has 4 replies
- Daniels118
- Posts: 503
- Joined: Wed Nov 17, 2021 9:04 pm
- Country: Italy
Re: How to save a user's (plugin-related) preferences?
The Home class allows to set custom properties.
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?
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?
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 [font=courier new]setModified[/font] 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 [font=courier new]setProperty[/font] / [font=courier new]getProperty[/font] in [font=courier new]UserPreferences[/font] class at the moment, but can save additional data at the same place as where [font=courier new]preferences.xm[/font] file is saved if needed.
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 [font=courier new]setProperty[/font] / [font=courier new]getProperty[/font] in [font=courier new]UserPreferences[/font] class at the moment, but can save additional data at the same place as where [font=courier new]preferences.xm[/font] file is saved if needed.
Emmanuel Puybaret, Sweet Home 3D creator
Re: How to save a user's (plugin-related) preferences?
Hey, saving per home/project is good for my purposes.
Thanks for the explanations!
Thanks for the explanations!
Who is online
Users browsing this forum: No registered users and 1 guest