summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
Diffstat (limited to 'options')
-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
8 files changed, 56 insertions, 54 deletions
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())