diff options
-rw-r--r-- | filter-kalman/kalman.cpp | 4 | ||||
-rw-r--r-- | gui/mapping-dialog.cpp | 8 | ||||
-rw-r--r-- | gui/options-dialog.cpp | 9 | ||||
-rw-r--r-- | opentrack/main-window.cpp | 17 | ||||
-rw-r--r-- | options/base-value.hpp | 13 | ||||
-rw-r--r-- | options/tie.cpp | 66 | ||||
-rw-r--r-- | options/tie.hpp | 32 | ||||
-rw-r--r-- | options/value-traits.hpp | 11 | ||||
-rw-r--r-- | options/value.hpp | 23 | ||||
-rw-r--r-- | spline/spline.cpp | 9 | ||||
-rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.cpp | 2 | ||||
-rw-r--r-- | tracker-easy/tracker-easy.cpp | 20 | ||||
-rw-r--r-- | tracker-neuralnet/ftnoir_tracker_neuralnet.cpp | 2 | ||||
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt_dialog.cpp | 16 | ||||
-rw-r--r-- | tracker-trackhat/camera.cpp | 4 | ||||
-rw-r--r-- | tracker-trackhat/dialog.cpp | 21 | ||||
-rw-r--r-- | video-ps3eye/module.cpp | 5 |
17 files changed, 125 insertions, 137 deletions
diff --git a/filter-kalman/kalman.cpp b/filter-kalman/kalman.cpp index 1960e0f6..a7d7aad8 100644 --- a/filter-kalman/kalman.cpp +++ b/filter-kalman/kalman.cpp @@ -265,8 +265,8 @@ dialog_kalman::dialog_kalman() tie_setting(s.noise_rot_slider_value, ui.noiseRotSlider); tie_setting(s.noise_pos_slider_value, ui.noisePosSlider); - connect(&s.noise_rot_slider_value, SIGNAL(valueChanged(const slider_value&)), this, SLOT(updateLabels(const slider_value&))); - connect(&s.noise_pos_slider_value, SIGNAL(valueChanged(const slider_value&)), this, SLOT(updateLabels(const slider_value&))); + s.noise_rot_slider_value.connect_to(this, &dialog_kalman::updateLabels); + s.noise_pos_slider_value.connect_to(this, &dialog_kalman::updateLabels); updateLabels(slider_value()); } diff --git a/gui/mapping-dialog.cpp b/gui/mapping-dialog.cpp index cdbf532e..bdf33a77 100644 --- a/gui/mapping-dialog.cpp +++ b/gui/mapping-dialog.cpp @@ -117,9 +117,7 @@ void mapping_dialog::load() if (altp) { - connect(&axis.opts.altp, - value_::value_changed<bool>(), - this, [&](bool f) { qfc.setEnabled(f); }); + axis.opts.altp.connect_to(this, [&](bool f) { qfc.setEnabled(f); }); qfc.setEnabled(axis.opts.altp); } @@ -164,8 +162,8 @@ void mapping_dialog::load() qfc.set_snap(.5, 1); - connect(&axis.opts.clamp_x_, value_::value_changed<int>(), &qfc, update_xstep); - connect(&axis.opts.clamp_y_, value_::value_changed<int>(), &qfc, update_ystep); + axis.opts.clamp_x_.connect_to(&qfc, update_xstep); + axis.opts.clamp_y_.connect_to(&qfc, update_ystep); // force signal to avoid duplicating the slot's logic qfc.set_config(&conf); diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp index ac4117bc..ab36d73b 100644 --- a/gui/options-dialog.cpp +++ b/gui/options-dialog.cpp @@ -167,13 +167,8 @@ options_dialog::options_dialog(std::unique_ptr<ITrackerDialog>& tracker_dialog_, { tmp val = val_; val.label->setText(kopts_to_string(val.opt)); - connect(&val.opt.keycode, - static_cast<void (value_::*)(const QString&) const>(&value_::valueChanged), - val.label, - [=](const QString&) { val.label->setText(kopts_to_string(val.opt)); }); - { - connect(val.button, &QPushButton::clicked, this, [=] { bind_key(val.opt, val.label); }); - } + val.opt.keycode.connect_to(val.label, [=] { val.label->setText(kopts_to_string(val.opt)); }, Qt::DirectConnection); + connect(val.button, &QPushButton::clicked, this, [=] { bind_key(val.opt, val.label); }); } auto add_module_tab = [this] (auto& place, auto&& dlg, const QString& label) { diff --git a/opentrack/main-window.cpp b/opentrack/main-window.cpp index b879e773..fadcf1e5 100644 --- a/opentrack/main-window.cpp +++ b/opentrack/main-window.cpp @@ -112,17 +112,9 @@ void main_window::init_dylibs() this, [this](const QString&) { pFilterDialog = nullptr; if (options_widget) options_widget->filter_module_changed(); }); #endif - connect(&m.tracker_dll, value_::value_changed<QString>(), - this, &main_window::save_modules, - Qt::DirectConnection); - - connect(&m.protocol_dll, value_::value_changed<QString>(), - this, &main_window::save_modules, - Qt::DirectConnection); - - connect(&m.filter_dll, value_::value_changed<QString>(), - this, &main_window::save_modules, - Qt::DirectConnection); + m.tracker_dll.connect_to(this, &main_window::save_modules, Qt::DirectConnection); + m.protocol_dll.connect_to(this, &main_window::save_modules, Qt::DirectConnection); + m.filter_dll.connect_to(this, &main_window::save_modules, Qt::DirectConnection); { struct list { @@ -239,8 +231,7 @@ void main_window::init_tray_menu() QObject::connect(&menu_action_exit, &QAction::triggered, this, &main_window::exit); tray_menu.addAction(&menu_action_exit); - connect(&s.tray_enabled, value_::value_changed<bool>(), - this, &main_window::ensure_tray); + s.tray_enabled.connect_to(this, &main_window::ensure_tray, Qt::DirectConnection); } void main_window::init_buttons() diff --git a/options/base-value.hpp b/options/base-value.hpp index eb8c89b7..81da0513 100644 --- a/options/base-value.hpp +++ b/options/base-value.hpp @@ -10,6 +10,7 @@ #include "value-traits.hpp" #include <utility> +#include <type_traits> #include <QObject> #include <QString> @@ -26,21 +27,15 @@ class OTR_OPTIONS_EXPORT value_ : public QObject { Q_OBJECT - template<typename t> using cv_qualified = detail::cv_qualified<t>; - template<typename t> - using signal_sig = void(value_::*)(cv_qualified<t>) const; +protected: + template<typename t> using signal_sig_ = void(value_::*)(detail::cv_qualified<detail::maybe_enum_type_t<t>>) const; + template<typename t> using slot_sig_ = void(value_::*)(detail::cv_qualified<detail::maybe_enum_type_t<t>>); public: QString name() const { return self_name; } value_(bundle const& b, const QString& name) noexcept; ~value_() override; - template<typename t> - static constexpr auto value_changed() - { - return static_cast<signal_sig<t>>(&value_::valueChanged); - } - static const bool TRACE_NOTIFY; signals: diff --git a/options/tie.cpp b/options/tie.cpp index 493ff551..0ac1c5bf 100644 --- a/options/tie.cpp +++ b/options/tie.cpp @@ -8,7 +8,6 @@ #include "tie.hpp" #include "compat/run-in-thread.hpp" -#include "compat/macros.hpp" #include "value-traits.hpp" @@ -20,16 +19,16 @@ void tie_setting(value<int>& v, QComboBox* cb) { cb->setCurrentIndex(v); v = cb->currentIndex(); - 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); + v.connect_to(cb, &QComboBox::setCurrentIndex); + v.connect_from(cb, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged)); } void tie_setting(value<QString>& v, QComboBox* cb) { cb->setCurrentText(v); v = cb->currentText(); - 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); + v.connect_to(cb, &QComboBox::currentTextChanged); + v.connect_from(cb, &QComboBox::setCurrentText); } void tie_setting(value<QVariant>& v, QComboBox* cb) @@ -57,60 +56,57 @@ void tie_setting(value<QVariant>& v, QComboBox* cb) else v = {}; - value_::connect(cb, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - &v, [cb, &v](int idx) { v = cb->itemData(idx); }, - v.DIRECT_CONNTYPE); - value_::connect(&v, value_::value_changed<QVariant>(), - cb, [set_idx](const QVariant& var) { set_idx(var); }, - v.SAFE_CONNTYPE); + v.connect_from(cb, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + [cb, &v](int idx) { v = cb->itemData(idx); }); + v.connect_to(cb, [fn = std::move(set_idx)](const QVariant& var) { fn(var); }); } void tie_setting(value<bool>& v, QRadioButton* cb) { cb->setChecked(v); - 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); + v.connect_to(cb, &QRadioButton::setChecked); + v.connect_from(cb, &QRadioButton::toggled); } void tie_setting(value<bool>& v, QCheckBox* cb) { cb->setChecked(v); - 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); + v.connect_to(cb, &QCheckBox::setChecked); + v.connect_from(cb, &QCheckBox::toggled); } void tie_setting(value<double>& v, QDoubleSpinBox* dsb) { dsb->setValue(v); - 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); + v.connect_to(dsb, &QDoubleSpinBox::setValue); + v.connect_from(dsb, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged)); } void tie_setting(value<int>& v, QSpinBox* sb) { sb->setValue(v); - 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); + v.connect_to(sb, &QSpinBox::setValue); + v.connect_from(sb, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged)); } void tie_setting(value<QString>& v, QLineEdit* le) { le->setText(v); - 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); + v.connect_to(le, &QLineEdit::setText); + v.connect_from(le, &QLineEdit::textChanged); } void tie_setting(value<QString>& v, QLabel* lb) { lb->setText(v); - value_::connect(&v, value_::value_changed<QString>(), lb, &QLabel::setText, v.SAFE_CONNTYPE); + v.connect_to(lb, &QLabel::setText); } void tie_setting(value<int>& v, QTabWidget* t) { t->setCurrentIndex(v); - 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); + v.connect_to(t, &QTabWidget::setCurrentIndex); + v.connect_from(t, &QTabWidget::currentChanged); } void tie_setting(value<slider_value>& v, QSlider* w) @@ -123,32 +119,24 @@ void tie_setting(value<slider_value>& v, QSlider* w) v = v().update_from_slider(w->value(), q_min, q_max); } - value_::connect(w, &QSlider::valueChanged, &v, [=, &v](int pos) - { - run_in_thread_sync(w, [&]() - { + v.connect_from(w, &QSlider::valueChanged, [=, &v](int pos) { + run_in_thread_sync(w, [&]() { const int q_min = w->minimum(); const int q_max = w->maximum(); v = v().update_from_slider(pos, q_min, q_max); w->setValue(v().to_slider_pos(q_min, q_max)); }); - }, - v.DIRECT_CONNTYPE); - - value_::connect(&v, - value_::value_changed<slider_value>(), - w, - [=, &v](double) { - run_in_thread_sync(w, [=, &v]() - { + }, v.DIRECT_CONNTYPE); + + v.connect_to(w, [=, &v](double) { + run_in_thread_sync(w, [=, &v]() { const int q_min = w->minimum(); const int q_max = w->maximum(); const int pos = v->to_slider_pos(q_min, q_max); v = v->update_from_slider(pos, q_min, q_max); w->setValue(pos); }); - }, - v.DIRECT_CONNTYPE); + }, v.DIRECT_CONNTYPE); } } // ns options diff --git a/options/tie.hpp b/options/tie.hpp index 46ade075..81567139 100644 --- a/options/tie.hpp +++ b/options/tie.hpp @@ -37,13 +37,9 @@ 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()); - value_::connect(cb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - &v, [&v, cb](int idx) { v = static_cast<t>(cb->itemData(idx).toInt()); }, - v.DIRECT_CONNTYPE); - - value_::connect(&v, value_::value_changed<int>(), - cb, [cb](int x) { cb->setCurrentIndex(cb->findData(x)); }, - v.SAFE_CONNTYPE); + v.connect_from(cb, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + [&v, cb](int idx) { v = static_cast<t>(cb->itemData(idx).toInt()); }); + v.connect_to(cb, [cb](int x) { cb->setCurrentIndex(cb->findData(x)); }); } template<typename t, typename From, typename To> @@ -52,23 +48,20 @@ 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()); - value_::connect(cb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - &v, [&v, cb, fn_to_value](int idx) { v = fn_to_value(idx, cb->currentData()); }, - v.DIRECT_CONNTYPE); - value_::connect(&v, value_::value_changed<t>(), - cb, [cb, fn_to_index](detail::cv_qualified<t>& v) { cb->setCurrentIndex(fn_to_index(v)); }, - v.DIRECT_CONNTYPE); + v.connect_from(cb, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + [&v, cb, fn = std::forward<To>(fn_to_value)](int idx) { v = fn(idx, cb->currentData()); }); + v.connect_to(cb, [cb, fn = std::forward<From>(fn_to_index)](detail::cv_qualified<t> v) { cb->setCurrentIndex(fn(v)); }); } template<typename t, typename F> void tie_setting(value<t>& v, QLabel* lb, F&& fun) { - auto closure = [lb, fun](detail::cv_qualified<t> v) { lb->setText(fun(v)); }; + auto closure = [lb, fn = std::forward<F>(fun)](detail::cv_qualified<t> v) { + lb->setText(fn(v)); + }; closure(v()); - value_::connect(&v, value_::value_changed<t>(), - lb, closure, - v.SAFE_CONNTYPE); + v.connect_to(lb, std::move(closure)); } template<typename t, typename F> @@ -78,10 +71,7 @@ void tie_setting(value<t>& v, QObject* obj, F&& fun) abort(); fun(v()); - - value_::connect(&v, value_::value_changed<t>(), - obj, fun, - v.DIRECT_CONNTYPE); + v.connect_to(obj, std::forward<F>(fun)); } OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QComboBox* cb); diff --git a/options/value-traits.hpp b/options/value-traits.hpp index 145cd924..e676f942 100644 --- a/options/value-traits.hpp +++ b/options/value-traits.hpp @@ -15,6 +15,17 @@ using cv_qualified = std::remove_cvref_t<t>, std::add_lvalue_reference_t<std::add_const_t<std::remove_cvref_t<t>>>>; +template<typename t, typename = void> +struct maybe_enum_type { + using type = t; +}; +template<typename t> +struct maybe_enum_type<t, std::enable_if_t<std::is_enum_v<t>>> { + using type = int; +}; + +template<typename t> using maybe_enum_type_t = typename maybe_enum_type<t>::type; + template<typename t, typename u = t, typename Enable = void> struct default_value_traits { diff --git a/options/value.hpp b/options/value.hpp index 090a7bdf..4476f8b7 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -27,10 +27,10 @@ namespace options::detail { { t x; public: - constexpr t const* operator->() const { return &x; } constexpr t* operator->() { return &x; } constexpr explicit dereference_wrapper(t&& x) : x(x) {} }; + template<typename t, typename...> /*MSVC workaround*/ static constexpr bool is_enum_v = std::is_enum_v<t>; } // ns options::detail namespace options { @@ -38,7 +38,7 @@ namespace options { template<typename t> class value final : public value_ { - static_assert(std::is_same_v<t, remove_cvref_t<t>>); + static_assert(std::is_same_v<t, std::remove_cvref_t<t>>); mutable QMutex mtx; const t def; mutable t cached_value; @@ -86,6 +86,9 @@ class value final : public value_ } public: + using signal_sig = typename value_::signal_sig_<t>; + using slot_sig = typename value_::slot_sig_<t>; + QVariant get_variant() const noexcept override { if (QVariant ret{b->get_variant(self_name)}; ret.isValid() && !ret.isNull()) @@ -195,6 +198,22 @@ public: { return static_cast<u>(get()); } + + template<typename Q, typename F> + QMetaObject::Connection + connect_to(Q* qobject, F&& writer, Qt::ConnectionType conn = Qt::QueuedConnection) { + return QObject::connect(this, static_cast<signal_sig>(&value<t>::valueChanged), qobject, std::forward<F>(writer), conn); + } + template<typename Q, typename F> + QMetaObject::Connection + connect_from(Q* qobject, F&& reader, Qt::ConnectionType conn = Qt::DirectConnection) { + return QObject::connect(qobject, std::forward<F>(reader), this, static_cast<slot_sig>(&value<t>::setValue), conn); + } + template<typename Q, typename F, typename G> + QMetaObject::Connection + connect_from(Q* qobject, F&& reader, G&& fn, Qt::ConnectionType conn = Qt::DirectConnection) { + return QObject::connect(qobject, std::forward<F>(reader), this, std::forward<G>(fn), conn); + } }; #if !defined OTR_OPTIONS_INST_VALUE diff --git a/spline/spline.cpp b/spline/spline.cpp index ecbfc3a0..b8f84df5 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -390,12 +390,9 @@ void spline::set_bundle(bundle b, const QString& axis_name, Axis axis) invalidate_settings_(); S = s; - conn_points = QObject::connect(&s->points, value_::value_changed<QList<QPointF>>(), - &*ctx, [this] { invalidate_settings(); }, Qt::DirectConnection); - conn_maxx = QObject::connect(&s->opts.clamp_x_, value_::value_changed<int>(), - &*ctx, [this](double) { invalidate_settings(); }, Qt::DirectConnection); - conn_maxy = QObject::connect(&s->opts.clamp_y_, value_::value_changed<int>(), - &*ctx, [this](double) { invalidate_settings(); }, Qt::DirectConnection); + conn_points = s->points.connect_to(&*ctx, &spline::invalidate_settings(), Qt::DirectConnection); + conn_maxx = s->opts.clamp_x_.connect_to(&*ctx, &spline::invalidate_settings, Qt::DirectConnection); + conn_maxy = s->opts.clamp_y_.connect_to(&*ctx, &spline::invalidate_settings(), Qt::DirectConnection); } emit S->recomputed(); diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index 1f39db32..26c803be 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -537,7 +537,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, value_::value_changed<QString>(), this, &aruco_dialog::update_camera_settings_state); + s.camera_name.connect_to(this, &aruco_dialog::update_camera_settings_state); update_camera_settings_state(s.camera_name); } diff --git a/tracker-easy/tracker-easy.cpp b/tracker-easy/tracker-easy.cpp index 7046a918..a4b7ca4c 100644 --- a/tracker-easy/tracker-easy.cpp +++ b/tracker-easy/tracker-easy.cpp @@ -59,31 +59,31 @@ namespace EasyTracker connect(&*iSettings.b, &bundle_::saving, this, &Tracker::CheckCamera, Qt::DirectConnection); connect(&*iSettings.b, &bundle_::reloading, this, &Tracker::CheckCamera, Qt::DirectConnection); - connect(&iSettings.fov, value_::value_changed<int>(), this, &Tracker::set_fov, Qt::DirectConnection); + iSettings.fov.connect_to(this, &Tracker::set_fov, Qt::DirectConnection); set_fov(iSettings.fov); // We could not get this working, nevermind //connect(&iSettings.cam_fps, value_::value_changed<int>(), this, &Tracker::SetFps, Qt::DirectConnection); // Make sure deadzones are updated whenever the settings are changed - connect(&iSettings.DeadzoneRectHalfEdgeSize, value_::value_changed<int>(), this, &Tracker::UpdateSettings, Qt::DirectConnection); + iSettings.DeadzoneRectHalfEdgeSize.connect_to(this, &Tracker::UpdateSettings, Qt::DirectConnection); // Update point extractor whenever some of the settings it needs are changed - connect(&iSettings.iMinBlobSize, value_::value_changed<int>(), this, &Tracker::UpdateSettings, Qt::DirectConnection); - connect(&iSettings.iMaxBlobSize, value_::value_changed<int>(), this, &Tracker::UpdateSettings, Qt::DirectConnection); + iSettings.iMinBlobSize.connect_to(this, &Tracker::UpdateSettings, Qt::DirectConnection); + iSettings.iMaxBlobSize.connect_to(this, &Tracker::UpdateSettings, Qt::DirectConnection); // Make sure solver is updated whenever the settings are changed - connect(&iSettings.PnpSolver, value_::value_changed<int>(), this, &Tracker::UpdateSettings, Qt::DirectConnection); + iSettings.PnpSolver.connect_to(this, &Tracker::UpdateSettings, Qt::DirectConnection); // Debug - connect(&iSettings.debug, value_::value_changed<bool>(), this, &Tracker::UpdateSettings, Qt::DirectConnection); + iSettings.debug.connect_to(this, &Tracker::UpdateSettings, Qt::DirectConnection); // Make sure model is updated whenever it is changed - connect(&iSettings.iCustomModelThree, value_::value_changed<bool>(), this, &Tracker::UpdateModel, Qt::DirectConnection); - connect(&iSettings.iCustomModelFour, value_::value_changed<bool>(), this, &Tracker::UpdateModel, Qt::DirectConnection); - connect(&iSettings.iCustomModelFive, value_::value_changed<bool>(), this, &Tracker::UpdateModel, Qt::DirectConnection); + iSettings.iCustomModelThree.connect_to(this, &Tracker::UpdateModel, Qt::DirectConnection); + iSettings.iCustomModelFour .connect_to(this, &Tracker::UpdateModel, Qt::DirectConnection); + iSettings.iCustomModelFive .connect_to(this, &Tracker::UpdateModel, Qt::DirectConnection); // Update model logic - #define UM(v) connect(&iSettings.v, value_::value_changed<int>(), this, &Tracker::UpdateModel, Qt::DirectConnection) + #define UM(v) iSettings.v.connect_to(this, &Tracker::UpdateModel, Qt::DirectConnection) UM(iVertexTopX); UM(iVertexTopY); UM(iVertexTopZ); UM(iVertexTopRightX); UM(iVertexTopRightY); UM(iVertexTopRightZ); UM(iVertexTopLeftX); UM(iVertexTopLeftY); UM(iVertexTopLeftZ); diff --git a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp index 62209978..49ca43ae 100644 --- a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp +++ b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp @@ -1200,7 +1200,7 @@ NeuralNetDialog::NeuralNetDialog() : connect(ui_.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui_.camera_settings, SIGNAL(clicked()), this, SLOT(camera_settings())); - connect(&settings_.camera_name, value_::value_changed<QString>(), this, &NeuralNetDialog::update_camera_settings_state); + settings_.camera_name.connect_to(this, &NeuralNetDialog::update_camera_settings_state); update_camera_settings_state(settings_.camera_name); diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index 160eb831..988239e2 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -120,18 +120,22 @@ TrackerDialog_PT::TrackerDialog_PT(const QString& module_name) : tie_setting(s.enable_point_filter, ui.enable_point_filter); tie_setting(s.point_filter_coefficient, ui.point_filter_slider); tie_setting(s.point_filter_limit, ui.point_filter_limit_slider); - connect(&s.point_filter_coefficient, value_::value_changed<slider_value>(), - ui.point_filter_label, [this] { ui.point_filter_label->setValue(*s.point_filter_coefficient); } ); - connect(&s.point_filter_limit, value_::value_changed<slider_value>(), ui.point_filter_limit_label, - [this] { ui.point_filter_limit_label->setValue(*s.point_filter_limit); }, Qt::QueuedConnection); + s.point_filter_coefficient.connect_to(ui.point_filter_label, [this](double x) { + ui.point_filter_label->setValue(x); + }); + + s.point_filter_limit.connect_to(ui.point_filter_limit_label, [this] { + ui.point_filter_limit_label->setValue(*s.point_filter_limit); + }); ui.point_filter_label->setValue(*s.point_filter_coefficient); ui.point_filter_limit_label->setValue(*s.point_filter_limit); tie_setting(s.point_filter_deadzone, ui.point_filter_deadzone_slider); ui.point_filter_deadzone_label->setValue(*s.point_filter_deadzone); - connect(&s.point_filter_deadzone, value_::value_changed<slider_value>(), ui.point_filter_deadzone_label, - [this] { ui.point_filter_deadzone_label->setValue(*s.point_filter_deadzone); }, Qt::QueuedConnection); + s.point_filter_deadzone.connect_to(ui.point_filter_deadzone_label, [this](double x) { + ui.point_filter_deadzone_label->setValue(x); + }); } QString TrackerDialog_PT::threshold_display_text(int threshold_value) diff --git a/tracker-trackhat/camera.cpp b/tracker-trackhat/camera.cpp index 74e35423..0c18dd03 100644 --- a/tracker-trackhat/camera.cpp +++ b/tracker-trackhat/camera.cpp @@ -57,9 +57,7 @@ trackhat_camera::trackhat_camera() for (auto* slider : { &t.exposure, &t.gain, /*&t.threshold,*/ }) { - QObject::connect(slider, options::value_::value_changed<options::slider_value>(), - &sig, &trackhat_impl::setting_receiver::settings_changed, - Qt::DirectConnection); + slider->connect_to(&sig, &trackhat_impl::setting_receiver::settings_changed, Qt::DirectConnection); } } diff --git a/tracker-trackhat/dialog.cpp b/tracker-trackhat/dialog.cpp index 4ef64f50..e18c89cf 100644 --- a/tracker-trackhat/dialog.cpp +++ b/tracker-trackhat/dialog.cpp @@ -37,8 +37,7 @@ trackhat_dialog::trackhat_dialog() tie_setting(t.exposure, ui.exposure_slider); ui.exposure_label->setValue((int)*t.exposure); - connect(&t.exposure, value_::value_changed<slider_value>(), ui.exposure_label, - [this] { ui.exposure_label->setValue((int)*t.exposure); }, Qt::QueuedConnection); + t.exposure.connect_to(ui.exposure_label, [this] { ui.exposure_label->setValue((int)*t.exposure); }); // gain @@ -48,8 +47,7 @@ trackhat_dialog::trackhat_dialog() tie_setting(t.gain, ui.gain_slider); ui.gain_label->setValue((int)*t.gain); - connect(&t.gain, value_::value_changed<slider_value>(), ui.gain_label, - [this] { ui.gain_label->setValue((int)*t.gain); }, Qt::QueuedConnection); + t.gain.connect_to(ui.gain_label, [this] { ui.gain_label->setValue((int)*t.gain); }); #if 0 // threshold @@ -66,21 +64,24 @@ trackhat_dialog::trackhat_dialog() // point filter ui.point_filter_limit_label->setValue(*t.point_filter_limit); - connect(&t.point_filter_limit, value_::value_changed<slider_value>(), ui.point_filter_limit_label, - [this] { ui.point_filter_limit_label->setValue(*t.point_filter_limit); }, Qt::QueuedConnection); + t.point_filter_limit.connect_to(ui.point_filter_limit_label, [this] { + ui.point_filter_limit_label->setValue(*t.point_filter_limit); + }); tie_setting(t.enable_point_filter, ui.enable_point_filter); tie_setting(t.point_filter_coefficient, ui.point_filter_slider); ui.point_filter_label->setValue(*t.point_filter_coefficient); - connect(&t.point_filter_coefficient, value_::value_changed<slider_value>(), ui.point_filter_label, - [this] { ui.point_filter_label->setValue(*t.point_filter_coefficient); }, Qt::QueuedConnection); + t.point_filter_coefficient.connect_to(ui.point_filter_label, [this] { + ui.point_filter_label->setValue(*t.point_filter_coefficient); + }); tie_setting(t.point_filter_deadzone, ui.point_filter_deadzone); ui.point_filter_deadzone_label->setValue(*t.point_filter_deadzone); - connect(&t.point_filter_deadzone, value_::value_changed<slider_value>(), ui.point_filter_deadzone_label, - [this] { ui.point_filter_deadzone_label->setValue(*t.point_filter_deadzone); }, Qt::QueuedConnection); + t.point_filter_deadzone.connect_to(ui.point_filter_deadzone_label, [this] { + ui.point_filter_deadzone_label->setValue(*t.point_filter_deadzone); + }); // led diff --git a/video-ps3eye/module.cpp b/video-ps3eye/module.cpp index 02543082..04e7ecbe 100644 --- a/video-ps3eye/module.cpp +++ b/video-ps3eye/module.cpp @@ -266,8 +266,9 @@ dialog::dialog(QWidget* parent) : QWidget(parent) tie_setting(s.gain, ui.gain_slider); ui.exposure_label->setValue((int)*s.exposure); ui.gain_label->setValue((int)*s.gain); - connect(&s.exposure, value_::value_changed<slider_value>(), this, [this](const slider_value&) { t.stop(); t.start(); }); - connect(&s.gain, value_::value_changed<slider_value>(), this, [this](const slider_value&) { t.stop(); t.start(); }); + s.exposure.connect_to(this, [this] { t.stop(); t.start(); }); + s.gain.connect_to(this, [this] { t.stop(); t.start(); }); + connect(ui.exposure_slider, &QSlider::valueChanged, ui.exposure_label, &QSpinBox::setValue); connect(ui.gain_slider, &QSlider::valueChanged, ui.gain_label, &QSpinBox::setValue); connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &dialog::do_ok); |