diff options
Diffstat (limited to 'opentrack/options.hpp')
-rw-r--r-- | opentrack/options.hpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/opentrack/options.hpp b/opentrack/options.hpp index 5511f567..b7cc44a4 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -302,6 +302,7 @@ namespace options { #define DEFINE_SLOT(t) void setValue(t datum) { store(datum); } #define DEFINE_SIGNAL(t) void valueChanged(t) public: + string name() { return self_name; } base_value(pbundle b, const string& name) : b(b), self_name(name) {} signals: DEFINE_SIGNAL(double); @@ -343,7 +344,7 @@ namespace options { } static constexpr const Qt::ConnectionType DIRECT_CONNTYPE = Qt::DirectConnection; static constexpr const Qt::ConnectionType SAFE_CONNTYPE = Qt::UniqueConnection; - value(pbundle b, const string& name, t def) : base_value(b, name) + value(pbundle b, const string& name, t def) : base_value(b, name), def(def) { QObject::connect(b.get(), SIGNAL(reloading()), this, SLOT(reload()), @@ -356,11 +357,13 @@ namespace options { operator t() { - return b->get<t>(self_name); + return b->contains(self_name) ? b->get<t>(self_name) : def; } void reload() override { *this = static_cast<t>(*this); } + private: + t def; }; struct opts |