hydrogen-music / hydrogen

The advanced drum machine for Linux, macOS, and Windows
http://www.hydrogen-music.org
GNU General Public License v2.0
1.04k stars 173 forks source link

Refactor Preferences and hydrogen.conf integrity test #2006

Closed theGreatWhiteShark closed 1 month ago

theGreatWhiteShark commented 1 month ago

This PR adds the last missing integrity test (for our config file hydrogen.conf). But it required some heavy refactoring.

Instead of having just the Preferences singleton to load system-level or user-level settings into, we now adhere to the pattern we already use for e.g. Song and Playlist and provide a load() method to retrieve a Preferences instance without altering anything within Hydrogen, a save() method and saveCopyAs() to store changes, as well as load*, set*, save* routines in CoreActionController, which can be used from e.g. the GUI part.

The MidiMap singleton as killed and is now a member variable of Preferences.

In addition, upgrading the user-level preferences file on startup was dropped as well. It is also kinda redundant since loading it produces an updated version in memory and when quitting Hydrogen this updated version is written to disk anyway.

I also refactored large parts of Preferences::load. Now, it uses the values assigned in the constructor(s) as default ones. This was already done in a lot of places. But not all. Some of the default values did already diverge.