Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 5
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 1085 times and has 4 replies Next Thread
shmuelzon
Newbie



Israel
Joined: Dec 24, 2023
Post Count: 13
Status: Offline
Reply to this Post  Reply with Quote 
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?

Thanks in advance!
[Jul 19, 2024, 3:14:51 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 439
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to save a user's (plugin-related) preferences?

The Home class allows to set custom properties.
[Jul 19, 2024, 9:49:56 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
shmuelzon
Newbie



Israel
Joined: Dec 24, 2023
Post Count: 13
Status: Offline
Reply to this Post  Reply with Quote 
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?
[Jul 20, 2024, 6:45:11 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9416
Status: Offline
Reply to this Post  Reply with Quote 
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
[Jul 20, 2024, 8:34:35 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
shmuelzon
Newbie



Israel
Joined: Dec 24, 2023
Post Count: 13
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to save a user's (plugin-related) preferences?

Hey, saving per home/project is good for my purposes.
Thanks for the explanations!
[Jul 20, 2024, 9:20:43 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved