summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
Diffstat (limited to 'options')
-rw-r--r--options/base-value.cpp5
-rw-r--r--options/base-value.hpp2
-rw-r--r--options/slider.hpp4
-rw-r--r--options/tie.cpp8
-rw-r--r--options/tie.hpp14
5 files changed, 24 insertions, 9 deletions
diff --git a/options/base-value.cpp b/options/base-value.cpp
index 29f4b496..a07886bb 100644
--- a/options/base-value.cpp
+++ b/options/base-value.cpp
@@ -16,6 +16,11 @@ base_value::~base_value()
b->on_value_destructed(self_name, this);
}
+void base_value::notify() const
+{
+ bundle_value_changed();
+}
+
void base_value::store(const QVariant& datum)
{
b->store_kv(self_name, datum);
diff --git a/options/base-value.hpp b/options/base-value.hpp
index 5106908d..dfb22670 100644
--- a/options/base-value.hpp
+++ b/options/base-value.hpp
@@ -41,6 +41,8 @@ public:
return static_cast<signal_sig<t>>(&base_value::valueChanged);
}
+ void notify() const;
+
signals:
OPENTRACK_DEFINE_SIGNAL(double);
OPENTRACK_DEFINE_SIGNAL(float);
diff --git a/options/slider.hpp b/options/slider.hpp
index bda1d398..da6bf214 100644
--- a/options/slider.hpp
+++ b/options/slider.hpp
@@ -8,6 +8,9 @@
#pragma once
#include "export.hpp"
+
+#include "compat/util.hpp"
+
#include <QMetaType>
#include <QDataStream>
#include <QDebug>
@@ -31,6 +34,7 @@ namespace options
slider_value& operator=(const slider_value& v);
bool operator==(const slider_value& v) const;
operator double() const { return cur_; }
+ explicit operator int() const { return iround(cur_); }
double cur() const { return cur_; }
double min() const { return min_; }
double max() const { return max_; }
diff --git a/options/tie.cpp b/options/tie.cpp
index 162a0f56..c0552d71 100644
--- a/options/tie.cpp
+++ b/options/tie.cpp
@@ -87,14 +87,6 @@ OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QSpinBox* sb)
base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.SAFE_CONNTYPE);
}
-OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QSlider* sl)
-{
- sl->setValue(v);
- v = sl->value();
- base_value::connect(sl, &QSlider::valueChanged, &v, base_value::signal_fun<int>(), v.DIRECT_CONNTYPE);
- base_value::connect(&v, base_value::signal_fun<int>(), sl, &QSlider::setValue, v.SAFE_CONNTYPE);
-}
-
OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QLineEdit* le)
{
le->setText(v);
diff --git a/options/tie.hpp b/options/tie.hpp
index 0a4ace74..b6bf32e9 100644
--- a/options/tie.hpp
+++ b/options/tie.hpp
@@ -63,13 +63,25 @@ void tie_setting(value<t>& v, QLabel* lb, F&& fun)
v.SAFE_CONNTYPE);
}
+template<typename t, typename F>
+void tie_setting(value<t>& v, QObject* obj, F&& fun)
+{
+ if (obj == nullptr)
+ abort();
+
+ fun(v());
+
+ base_value::connect(&v, base_value::signal_fun<t>(),
+ obj, fun,
+ v.DIRECT_CONNTYPE);
+}
+
OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QComboBox* cb);
OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QComboBox* cb);
OTR_OPTIONS_EXPORT void tie_setting(value<QVariant>& v, QComboBox* cb);
OTR_OPTIONS_EXPORT void tie_setting(value<bool>& v, QCheckBox* cb);
OTR_OPTIONS_EXPORT void tie_setting(value<double>& v, QDoubleSpinBox* dsb);
OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QSpinBox* sb);
-OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QSlider* sl);
OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QLineEdit* le);
OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QLabel* lb);
OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QTabWidget* t);