From 913f41a7d5f2605da32be95b35c9a9df35a53fd8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 18 Jun 2015 10:44:24 +0200 Subject: options: return default value after revert, not type's default value Issue: #173 --- opentrack/options.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'opentrack/options.hpp') 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(self_name); + return b->contains(self_name) ? b->get(self_name) : def; } void reload() override { *this = static_cast(*this); } + private: + t def; }; struct opts -- cgit v1.2.3