Extension Storing Settings

I’m currently searching for the best way to store some settings for an extension, like show or hide the context menu (just an example).

I’ve read this topic, but it’s like six years old and maybe there’s some other ways to explore.

Any advice?

This is a year later:

1 Like

What about this one?
write_default

You can read it with:
read_default

1 Like

I’ve used those methods most of the time in my extensions. Just be aware that there are some data types they can’t capture or may distort. For example, I vaguely remember that an empty array will come back as nil? Test to make sure they handle what you need correctly. You may need to resort to something like JSON to assure correct storage and retrieval.

2 Likes

These have another drawback (although I myself use them in some quick and dirty plugins.)

The drawback (besides what Steve mentioned) is that these settings are stored in the %LocalAppData%"PrivatePreferences.json" file along with application interface metrics.

In recent versions on MS Windows using the Qt GUI framework, this JSON file is often corrupted and causes application crashes. The usual fix is to manually delete the whole file and then the user loses all settings for plugins and the application. A restart will regenerate the file back to “factory defaults” for the application settings, but all the specific plugin settings will need to be initialized by the individual extensions as if they were just installed.


So, it may be better for you to go with your own separate JSON files.

I’ve shown how to do this in multiple topics here. I’ll see if I can find some links …

1 Like

What I said and posted in that topic at post 14 …

… is all still relevant. It is all basic computer file facts that will not change.


Still looking for my posts on saving Ruby HashJSON file.

2 Likes

Here are a few editions of JSON settings code I have posted in the past …

Such a set of methods could be part of your standard extension template file(s).

2 Likes

Hi there @rtches. Thank you so much for this info, I’ll give it a try!

Good to know, thank you for the advice!

Thank you, Dan. I’ve already seen some of the posts you’re sending (which I’m going to read again carefully), but I preferred to ask just in case there’s some info or new ways to do that (they’re a few years old by now).

Have a nice day!

1 Like