diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-06-18 10:45:39 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-06-18 10:45:39 +0200 |
commit | afc02432a3d9e66a6279ed6176dda5b87ccd9818 (patch) | |
tree | c560bfbbee794d88e62d8c514973a346239ec9ca /opentrack/options.hpp | |
parent | 8e022f0d1ad5628c2bf9a97a16b16fd1cff5196c (diff) | |
parent | 913f41a7d5f2605da32be95b35c9a9df35a53fd8 (diff) |
Merge branch 'unstable' into trackhat-ui
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 a8880cad..06697631 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -301,6 +301,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); @@ -342,7 +343,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()), @@ -355,11 +356,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 |