summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
Diffstat (limited to 'options')
-rw-r--r--options/base-value.hpp4
-rw-r--r--options/value-traits.hpp32
2 files changed, 7 insertions, 29 deletions
diff --git a/options/base-value.hpp b/options/base-value.hpp
index 6a4709ee..14eaeb10 100644
--- a/options/base-value.hpp
+++ b/options/base-value.hpp
@@ -43,8 +43,6 @@ public:
return static_cast<signal_sig<t>>(&value_::valueChanged);
}
- void notify() const;
-
signals:
OTR_OPTIONS_SIGNAL(double);
OTR_OPTIONS_SIGNAL(float);
@@ -96,6 +94,8 @@ public slots:
virtual void bundle_value_changed() const = 0;
virtual void set_to_default() = 0;
+ void notify() const;
+
friend void ::options::detail::set_value_to_default(value_* val);
};
diff --git a/options/value-traits.hpp b/options/value-traits.hpp
index 31b6b534..f5b74f73 100644
--- a/options/value-traits.hpp
+++ b/options/value-traits.hpp
@@ -17,10 +17,9 @@ struct value_traits;
template<typename t, typename u = t, typename Enable = void>
struct default_value_traits
{
- using stored_type = std::decay_t<u>;
- using value_type = std::decay_t<t>;
-
- using self = value_traits<t>;
+ using value_type = t;
+ using stored_type = u;
+ using self = value_traits<value_type>;
static value_type value_with_default(const value_type& val, const value_type&)
{
@@ -91,33 +90,12 @@ struct value_traits<double> : default_value_traits<double>
value_type x_, y_;
- return I(std::round(std::modf(x, &x_) * K)) == I(std::round(std::modf(y, &y_) * K)) &&
- I(std::round(x_)) == I(std::round(y_));
+ return I(std::modf(x, &x_) * K) == I(std::modf(y, &y_) * K) &&
+ I(x_) == I(y_);
}
}
};
-template<> struct value_traits<bool> : default_value_traits<bool, int>
-{
- static stored_type storage_from_qvariant(const QVariant& x)
- {
- if (x.type() == QVariant::String)
- return x.toBool();
- else
- return !!x.toInt();
- }
-
- static QVariant qvariant_from_storage(const stored_type& val)
- {
- return QVariant::fromValue<int>(!!val);
- }
-
- static value_type value_from_storage(const stored_type& x)
- {
- return !!x;
- }
-};
-
template<> struct value_traits<float> : value_traits<float, double>
{
static constexpr inline value_type pass_value(const value_type& x) { return x; }