QSettings Config Groups

Rosegarden currently uses a mixture of idioms after the conversion to use QSettings for storing user preferences. The first type of code looks like:

    settings.beginGroup("Lazy Options Directly in a String");

The second type of code looks like:

    #include "misc/ConfigGroups.h"
    QSettings settings;

It is always preferable to use the second idiom whenever you have some new need of a new settings category. Take the time to edit and include misc/ConfigGroups.h, and use the constant defined there throughout the code. This does mean some extra work and compile time, but in the long run having the discipline to use ConfigGroups.h throughout lowers our chances of having stupid settings-related bugs where one piece of code reads from “Lazy Options Directly in a String” and another piece writes to “LazyOptionsDirectlyinaString” or what have you.

I would go so far as to say that whenever you encounter the lazy type, it would be good to take a moment to go fix it. There aren't too many of the lazy type left, and we could make them go away pretty quickly, and avoid future “settings amnesia” bugs.

Whether you take it upon yourself to do these cleanups or not, please use ConfigGroups.h in any new code. Also, please feel free to create new ConfigGroups as seems appropriate. For example, when I did the work to make windows remember their positions, I put all window positions into the same ConfigGroup for consistency across the application, and easy block copying of the code snippet to make the save/restore work. You certainly don't need to feel limited to the ConfigGroups that already exist.

NOTE: Oh, and you should avoid using spaces in the ConfigGroup strings. Either use underscores (Collapsing_Frame) or run the words together (CollapsingFrame). It is legal to use spaces, but Qt escapes them out, and this makes the config file difficult to read when it becomes necessary to debug it. “Collapsing Frame” becomes “Collapsing%20Frame” and I find that extremely irritating, so I would prefer to avoid the problem by leaving spaces (and any other characters which would need to be escaped) out of these strings. Thanks everyone.

dev/config_groups_config_groups.txt · Last modified: 2022/05/06 16:07 (external edit)
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki