summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-06-26 22:52:18 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-06-26 23:05:21 +0200
commitee0dd3b6d5ad2b6083372f4e4f0cb57a45aaaff2 (patch)
treedc9374f588200a53a4c2ef556293e176cec97975
parenta131d0850c731b6b564e493db7148267ceea7e8b (diff)
options/base-value: rename to `value_'
-rw-r--r--gui/mapping-dialog.cpp6
-rw-r--r--gui/settings.cpp2
-rw-r--r--options/base-value.cpp10
-rw-r--r--options/base-value.hpp16
-rw-r--r--options/bundle.cpp4
-rw-r--r--options/bundle.hpp2
-rw-r--r--options/connector.hpp6
-rw-r--r--options/tie.cpp56
-rw-r--r--options/tie.hpp12
-rw-r--r--options/value.hpp4
-rw-r--r--spline/spline.cpp4
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.cpp2
-rw-r--r--variant/default/main-window.cpp8
13 files changed, 67 insertions, 65 deletions
diff --git a/gui/mapping-dialog.cpp b/gui/mapping-dialog.cpp
index c6e49cee..83a045a0 100644
--- a/gui/mapping-dialog.cpp
+++ b/gui/mapping-dialog.cpp
@@ -120,7 +120,7 @@ void mapping_dialog::load()
if (altp)
{
connect(&axis.opts.altp,
- base_value::value_changed<bool>(),
+ value_::value_changed<bool>(),
this,
[&](bool f) {qfc.setEnabled(f); qfc.force_redraw();});
qfc.setEnabled(axis.opts.altp);
@@ -164,8 +164,8 @@ void mapping_dialog::load()
else
qfc.set_snap(.5, 1);
- connect(&axis.opts.clamp_x_, base_value::value_changed<int>(), &qfc, update_xstep);
- connect(&axis.opts.clamp_y_, base_value::value_changed<int>(), &qfc, update_ystep);
+ connect(&axis.opts.clamp_x_, value_::value_changed<int>(), &qfc, update_xstep);
+ connect(&axis.opts.clamp_y_, value_::value_changed<int>(), &qfc, update_ystep);
// force signal to avoid duplicating the slot's logic
qfc.setConfig(&conf);
diff --git a/gui/settings.cpp b/gui/settings.cpp
index d280a9b7..31bbd87b 100644
--- a/gui/settings.cpp
+++ b/gui/settings.cpp
@@ -150,7 +150,7 @@ options_dialog::options_dialog(std::function<void(bool)>&& pause_keybindings) :
tmp val = val_;
val.label->setText(kopts_to_string(val.opt));
connect(&val.opt.keycode,
- static_cast<void (base_value::*)(const QString&) const>(&base_value::valueChanged),
+ static_cast<void (value_::*)(const QString&) const>(&value_::valueChanged),
val.label,
[=](const QString&) { val.label->setText(kopts_to_string(val.opt)); });
{
diff --git a/options/base-value.cpp b/options/base-value.cpp
index 6c287321..dbeabbea 100644
--- a/options/base-value.cpp
+++ b/options/base-value.cpp
@@ -2,7 +2,7 @@
using namespace options;
-base_value::base_value(bundle b, const QString& name, base_value::comparator cmp, std::type_index type_idx) :
+value_::value_(bundle b, const QString& name, value_::comparator cmp, std::type_index type_idx) :
b(b),
self_name(name),
cmp(cmp),
@@ -11,17 +11,17 @@ base_value::base_value(bundle b, const QString& name, base_value::comparator cmp
b->on_value_created(name, this);
}
-base_value::~base_value()
+value_::~value_()
{
b->on_value_destructed(self_name, this);
}
-void base_value::notify() const
+void value_::notify() const
{
bundle_value_changed();
}
-void base_value::store(const QVariant& datum)
+void value_::store(const QVariant& datum)
{
b->store_kv(self_name, datum);
}
@@ -29,7 +29,7 @@ void base_value::store(const QVariant& datum)
namespace options {
namespace detail {
-void set_base_value_to_default(base_value* val)
+void set_base_value_to_default(value_* val)
{
val->set_to_default();
}
diff --git a/options/base-value.hpp b/options/base-value.hpp
index b094d693..5b924ab3 100644
--- a/options/base-value.hpp
+++ b/options/base-value.hpp
@@ -3,9 +3,10 @@
#include "bundle.hpp"
#include "slider.hpp"
#include "connector.hpp"
+#include "metatype.hpp"
#include "export.hpp"
-#include "compat/meta.hpp"
+#include "compat/macros.hpp"
#include <QObject>
#include <QString>
@@ -20,7 +21,7 @@
namespace options {
-class OTR_OPTIONS_EXPORT base_value : public QObject
+class OTR_OPTIONS_EXPORT value_ : public QObject
{
Q_OBJECT
@@ -28,20 +29,20 @@ class OTR_OPTIONS_EXPORT base_value : public QObject
using comparator = bool(*)(const QVariant& val1, const QVariant& val2);
template<typename t>
- using signal_sig = void(base_value::*)(cv_qualified<t>) const;
+ using signal_sig = void(value_::*)(cv_qualified<t>) const;
public:
bundle get_bundle() { return b; }
QString name() const { return self_name; }
- base_value(bundle b, const QString& name, comparator cmp, std::type_index type_idx);
- ~base_value() override;
+ value_(bundle b, const QString& name, comparator cmp, std::type_index type_idx);
+ ~value_() override;
// MSVC has ODR problems in 15.4
// no C++17 "constexpr inline" for data declarations in MSVC
template<typename t>
constexpr static auto value_changed()
{
- return static_cast<signal_sig<t>>(&base_value::valueChanged);
+ return static_cast<signal_sig<t>>(&value_::valueChanged);
}
void notify() const;
@@ -63,6 +64,7 @@ signals:
OPENTRACK_DEFINE_SIGNAL(const QList<QString>&);
OPENTRACK_DEFINE_SIGNAL(const QList<slider_value>&);
OPENTRACK_DEFINE_SIGNAL(const QList<QPointF>&);
+
protected:
bundle b;
QString self_name;
@@ -98,7 +100,7 @@ public slots:
virtual void bundle_value_changed() const = 0;
virtual void set_to_default() = 0;
- friend void ::options::detail::set_base_value_to_default(base_value* val);
+ friend void ::options::detail::set_base_value_to_default(value_* val);
};
} //ns options
diff --git a/options/bundle.cpp b/options/bundle.cpp
index 4a133402..e0db3fb3 100644
--- a/options/bundle.cpp
+++ b/options/bundle.cpp
@@ -12,7 +12,7 @@
#include <QThread>
#include <QApplication>
-using options::base_value;
+using options::value_;
namespace options
{
@@ -53,7 +53,7 @@ void bundle::set_all_to_default()
{
QMutexLocker l(&mtx);
- forall([](const QString&, base_value* val) { set_base_value_to_default(val); });
+ forall([](const QString&, value_* val) { set_base_value_to_default(val); });
if (is_modified())
group::mark_ini_modified();
diff --git a/options/bundle.hpp b/options/bundle.hpp
index 3ab6f74a..98e194db 100644
--- a/options/bundle.hpp
+++ b/options/bundle.hpp
@@ -31,7 +31,7 @@ namespace options {
namespace detail {
-void set_base_value_to_default(base_value* val);
+void set_base_value_to_default(value_* val);
struct bundler;
diff --git a/options/connector.hpp b/options/connector.hpp
index 5091ae67..68e86096 100644
--- a/options/connector.hpp
+++ b/options/connector.hpp
@@ -22,15 +22,15 @@
namespace options {
-class base_value;
+class value_;
namespace detail {
class OTR_OPTIONS_EXPORT connector
{
- friend class ::options::base_value;
+ friend class ::options::value_;
- using value_type = base_value*;
+ using value_type = value_*;
using value_vec = std::vector<value_type>;
using comparator = bool(*)(const QVariant&, const QVariant&);
using tt = std::tuple<value_vec, comparator, std::type_index>;
diff --git a/options/tie.cpp b/options/tie.cpp
index 0042a0fb..9de3df4c 100644
--- a/options/tie.cpp
+++ b/options/tie.cpp
@@ -15,16 +15,16 @@ OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QComboBox* cb)
{
cb->setCurrentIndex(v);
v = cb->currentIndex();
- base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE);
- base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE);
+ value_::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE);
+ value_::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE);
}
OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QComboBox* cb)
{
cb->setCurrentText(v);
v = cb->currentText();
- base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(const QString&)), v.DIRECT_CONNTYPE);
- base_value::connect(&v, SIGNAL(valueChanged(const QString&)), cb, SLOT(setCurrentText(const QString&)), v.SAFE_CONNTYPE);
+ value_::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(const QString&)), v.DIRECT_CONNTYPE);
+ value_::connect(&v, SIGNAL(valueChanged(const QString&)), cb, SLOT(setCurrentText(const QString&)), v.SAFE_CONNTYPE);
}
OTR_OPTIONS_EXPORT void tie_setting(value<QVariant>& v, QComboBox* cb)
@@ -52,13 +52,13 @@ OTR_OPTIONS_EXPORT void tie_setting(value<QVariant>& v, QComboBox* cb)
else
v = QVariant(QVariant::Invalid);
- base_value::connect(cb, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
- &v, [cb, &v](int idx) {
+ value_::connect(cb, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ &v, [cb, &v](int idx) {
v = cb->itemData(idx);
}, v.DIRECT_CONNTYPE);
- base_value::connect(&v, base_value::value_changed<QVariant>(),
- cb,
- [cb, set_idx](const QVariant& var) {
+ value_::connect(&v, value_::value_changed<QVariant>(),
+ cb,
+ [cb, set_idx](const QVariant& var) {
run_in_thread_sync(cb, [&] {
set_idx(var);
});
@@ -70,42 +70,42 @@ OTR_OPTIONS_EXPORT void tie_setting(value<QVariant>& v, QComboBox* cb)
OTR_OPTIONS_EXPORT void tie_setting(value<bool>& v, QCheckBox* cb)
{
cb->setChecked(v);
- base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.DIRECT_CONNTYPE);
- base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.SAFE_CONNTYPE);
+ value_::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.DIRECT_CONNTYPE);
+ value_::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.SAFE_CONNTYPE);
}
OTR_OPTIONS_EXPORT void tie_setting(value<double>& v, QDoubleSpinBox* dsb)
{
dsb->setValue(v);
- base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.DIRECT_CONNTYPE);
- base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.SAFE_CONNTYPE);
+ value_::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.DIRECT_CONNTYPE);
+ value_::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.SAFE_CONNTYPE);
}
OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QSpinBox* sb)
{
sb->setValue(v);
- base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE);
- base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.SAFE_CONNTYPE);
+ value_::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE);
+ value_::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.SAFE_CONNTYPE);
}
OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QLineEdit* le)
{
le->setText(v);
- base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.DIRECT_CONNTYPE);
- base_value::connect(&v, base_value::value_changed<QString>(), le, &QLineEdit::setText, v.SAFE_CONNTYPE);
+ value_::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.DIRECT_CONNTYPE);
+ value_::connect(&v, value_::value_changed<QString>(), le, &QLineEdit::setText, v.SAFE_CONNTYPE);
}
OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QLabel* lb)
{
lb->setText(v);
- base_value::connect(&v, base_value::value_changed<QString>(), lb, &QLabel::setText, v.SAFE_CONNTYPE);
+ value_::connect(&v, value_::value_changed<QString>(), lb, &QLabel::setText, v.SAFE_CONNTYPE);
}
OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QTabWidget* t)
{
t->setCurrentIndex(v);
- base_value::connect(t, SIGNAL(currentChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE);
- base_value::connect(&v, SIGNAL(valueChanged(int)), t, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE);
+ value_::connect(t, SIGNAL(currentChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE);
+ value_::connect(&v, SIGNAL(valueChanged(int)), t, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE);
}
OTR_OPTIONS_EXPORT void tie_setting(value<slider_value>& v, QSlider* w)
@@ -118,10 +118,10 @@ OTR_OPTIONS_EXPORT void tie_setting(value<slider_value>& v, QSlider* w)
v = v().update_from_slider(w->value(), q_min, q_max);
}
- base_value::connect(w,
- &QSlider::valueChanged,
- &v,
- [=, &v](int pos)
+ value_::connect(w,
+ &QSlider::valueChanged,
+ &v,
+ [=, &v](int pos)
{
run_in_thread_sync(w, [&]()
{
@@ -133,10 +133,10 @@ OTR_OPTIONS_EXPORT void tie_setting(value<slider_value>& v, QSlider* w)
},
v.DIRECT_CONNTYPE);
- base_value::connect(&v,
- base_value::value_changed<slider_value>(),
- w,
- [=, &v](double) {
+ value_::connect(&v,
+ value_::value_changed<slider_value>(),
+ w,
+ [=, &v](double) {
run_in_thread_sync(w, [=, &v]()
{
const int q_min = w->minimum();
diff --git a/options/tie.hpp b/options/tie.hpp
index ff82142e..59fd0da1 100644
--- a/options/tie.hpp
+++ b/options/tie.hpp
@@ -37,7 +37,7 @@ std::enable_if_t<std::is_enum_v<t>> tie_setting(value<t>& v, QComboBox* cb)
cb->setCurrentIndex(cb->findData(int(static_cast<t>(v))));
v = static_cast<t>(cb->currentData().toInt());
- base_value::connect(cb,
+ value_::connect(cb,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
&v, [&v, cb](int idx) {
run_in_thread_sync(cb, [&] {
@@ -46,7 +46,7 @@ std::enable_if_t<std::is_enum_v<t>> tie_setting(value<t>& v, QComboBox* cb)
},
v.DIRECT_CONNTYPE);
- base_value::connect(&v, base_value::value_changed<int>(),
+ value_::connect(&v, value_::value_changed<int>(),
cb, [cb](int x) {
run_in_thread_sync(cb, [=] { cb->setCurrentIndex(cb->findData(x)); });
},
@@ -59,13 +59,13 @@ void tie_setting(value<t>& v, QComboBox* cb, From&& fn_to_index, To&& fn_to_valu
cb->setCurrentIndex(fn_to_index(v));
v = fn_to_value(cb->currentIndex(), cb->currentData());
- base_value::connect(cb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ value_::connect(cb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
&v, [&v, cb, fn_to_value](int idx) {
run_in_thread_sync(cb, [&] {
v = fn_to_value(idx, cb->currentData());
});
}, v.DIRECT_CONNTYPE);
- base_value::connect(&v, base_value::value_changed<t>(),
+ value_::connect(&v, value_::value_changed<t>(),
cb, [&v, cb, fn_to_index](cv_qualified<t>& v) {
run_in_thread_sync(cb, [&] {
cb->setCurrentIndex(fn_to_index(v));
@@ -79,7 +79,7 @@ void tie_setting(value<t>& v, QLabel* lb, F&& fun)
auto closure = [=](cv_qualified<t> x) { lb->setText(fun(x)); };
closure(v());
- base_value::connect(&v, base_value::value_changed<t>(),
+ value_::connect(&v, value_::value_changed<t>(),
lb, closure,
v.SAFE_CONNTYPE);
}
@@ -92,7 +92,7 @@ void tie_setting(value<t>& v, QObject* obj, F&& fun)
fun(v());
- base_value::connect(&v, base_value::value_changed<t>(),
+ value_::connect(&v, value_::value_changed<t>(),
obj, fun,
v.DIRECT_CONNTYPE);
}
diff --git a/options/value.hpp b/options/value.hpp
index 42e72e50..f1e44677 100644
--- a/options/value.hpp
+++ b/options/value.hpp
@@ -32,7 +32,7 @@
namespace options {
template<typename t>
-class value final : public base_value
+class value final : public value_
{
using traits = detail::value_traits<t, t, void>;
using stored_type = typename traits::stored_type;
@@ -76,7 +76,7 @@ public:
cc_noinline
value(bundle b, const QString& name, t def) :
- base_value(b, name, &is_equal, std::type_index(typeid(stored_type))),
+ value_(b, name, &is_equal, std::type_index(typeid(stored_type))),
def(def)
{
if (!self_name.isEmpty())
diff --git a/spline/spline.cpp b/spline/spline.cpp
index 64a9142d..fc437bb9 100644
--- a/spline/spline.cpp
+++ b/spline/spline.cpp
@@ -355,9 +355,9 @@ void spline::set_bundle(bundle b, const QString& axis_name, Axis axis)
s.get(), [&] { invalidate_settings(); });
// this isn't strictly necessary for the spline but helps the widget
- conn_maxx = QObject::connect(&s->opts.clamp_x_, base_value::value_changed<int>(),
+ conn_maxx = QObject::connect(&s->opts.clamp_x_, value_::value_changed<int>(),
ctx.get(), [&](double) { invalidate_settings(); });
- conn_maxy = QObject::connect(&s->opts.clamp_y_, base_value::value_changed<int>(),
+ conn_maxy = QObject::connect(&s->opts.clamp_y_, value_::value_changed<int>(),
ctx.get(), [&](double) { invalidate_settings(); });
}
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp
index a63edb8b..cdadf2e9 100644
--- a/tracker-aruco/ftnoir_tracker_aruco.cpp
+++ b/tracker-aruco/ftnoir_tracker_aruco.cpp
@@ -474,7 +474,7 @@ aruco_dialog::aruco_dialog() :
connect(&calib_timer, SIGNAL(timeout()), this, SLOT(update_tracker_calibration()));
connect(ui.camera_settings, SIGNAL(clicked()), this, SLOT(camera_settings()));
- connect(&s.camera_name, base_value::value_changed<QString>(), this, &aruco_dialog::update_camera_settings_state);
+ connect(&s.camera_name, value_::value_changed<QString>(), this, &aruco_dialog::update_camera_settings_state);
update_camera_settings_state(s.camera_name);
}
diff --git a/variant/default/main-window.cpp b/variant/default/main-window.cpp
index efc0882e..8e5cd10c 100644
--- a/variant/default/main-window.cpp
+++ b/variant/default/main-window.cpp
@@ -175,15 +175,15 @@ main_window::main_window() :
this,
[&](const QString&) { if (pFilterDialog) pFilterDialog = nullptr; });
- connect(&m.tracker_dll, base_value::value_changed<QString>(),
+ connect(&m.tracker_dll, value_::value_changed<QString>(),
this, &main_window::save_modules,
Qt::DirectConnection);
- connect(&m.protocol_dll, base_value::value_changed<QString>(),
+ connect(&m.protocol_dll, value_::value_changed<QString>(),
this, &main_window::save_modules,
Qt::DirectConnection);
- connect(&m.filter_dll, base_value::value_changed<QString>(),
+ connect(&m.filter_dll, value_::value_changed<QString>(),
this, &main_window::save_modules,
Qt::DirectConnection);
@@ -315,7 +315,7 @@ void main_window::init_tray()
tray_menu.addAction(&menu_action_exit);
connect(&s.tray_enabled,
- static_cast<void (base_value::*)(bool) const>(&base_value::valueChanged),
+ static_cast<void (value_::*)(bool) const>(&value_::valueChanged),
this,
&main_window::ensure_tray);
}