summaryrefslogtreecommitdiffhomepage
path: root/opentrack/options.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-06-18 10:44:24 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-06-18 10:45:20 +0200
commit913f41a7d5f2605da32be95b35c9a9df35a53fd8 (patch)
tree8deef8b46ea3f3443039fbba883f9ec42983f75f /opentrack/options.hpp
parent436ae875436754c1146da144da52eac60ae4e631 (diff)
options: return default value after revert, not type's default value
Issue: #173
Diffstat (limited to 'opentrack/options.hpp')
-rw-r--r--opentrack/options.hpp7
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