Add settings API and specification

The details of the API are in the `/docs/specsSettings-API.md` file.

The enums do not list all available settings, more are to be added as
the settings API replaces inline QSettings calls.
This commit is contained in:
Vasily
2019-12-03 08:26:10 +01:00
committed by username223
parent 61fd3dde79
commit c1690056cc
13 changed files with 1131 additions and 5 deletions
+76
View File
@@ -0,0 +1,76 @@
#include <utility>
#include <QSettings>
#include <easylogging++.h>
#include "../overlaycontroller.h"
#include "settings_controller.h"
namespace settings
{
SettingsController& getSettingsController()
{
static SettingsController s{};
return s;
}
void saveChangedSettings()
{
getSettingsController().saveChangedSettings();
}
void saveAllSettings()
{
LOG( INFO ) << "Saving all settings.";
getSettingsController().saveAllSettings();
LOG( INFO ) << "All settings saved.";
}
[[nodiscard]] bool getSetting( const BoolSetting setting )
{
return getSettingsController().getSetting<bool>( setting );
}
void setSetting( const BoolSetting setting, const bool value )
{
getSettingsController().setSetting( setting, value );
}
[[nodiscard]] double getSetting( const DoubleSetting setting )
{
return getSettingsController().getSetting<double>( setting );
}
void setSetting( const DoubleSetting setting, const double value )
{
getSettingsController().setSetting( setting, value );
}
[[nodiscard]] int getSetting( const IntSetting setting )
{
return getSettingsController().getSetting<int>( setting );
}
void setSetting( const IntSetting setting, const int value )
{
getSettingsController().setSetting( setting, value );
}
[[nodiscard]] std::string getSetting( const StringSetting setting )
{
return getSettingsController().getSetting<std::string>( setting );
}
void setSetting( const StringSetting setting, const std::string value )
{
getSettingsController().setSetting( setting, value );
}
std::string initializeAndGetSettingsPath()
{
// The static object is initialized the first time the function is called.
// Having a dedicated function for this allows more control over when this
// happens.
return getSettingsController().getSettingsFileName();
}
} // namespace settings