settings file and save/restore ui state

This commit is contained in:
2019-04-14 18:03:41 +02:00
parent ada1afbac2
commit a8d475fbfb
15 changed files with 596 additions and 38 deletions

35
src/settings.h Normal file
View File

@@ -0,0 +1,35 @@
#pragma once
#include "serializer.h"
class Settings : public Serializer::Descriptor
{
public:
Settings() { class_id = "pref"; }
static Settings I;
static bool load();
static bool save();
static bool has(const std::string& key)
{
return I.Descriptor::has(key);
}
template <typename T>
static void set(const std::string& key, const T value)
{
I.Descriptor::set(key, value);
}
template <typename T>
static std::shared_ptr<T> get(const std::string& key)
{
return I.Descriptor::get<T>(key);
}
template <typename T, typename D = decltype(T::value)>
static void value(const std::string& key, D& dest)
{
I.Descriptor::value<T, D>(key, dest);
}
template <typename T>
static auto value(const std::string& key)
{
return I.Descriptor::value<T>(key);
}
};