diff options
Diffstat (limited to 'options/tie.cpp')
-rw-r--r-- | options/tie.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/options/tie.cpp b/options/tie.cpp index 43e6c596..adf26b53 100644 --- a/options/tie.cpp +++ b/options/tie.cpp @@ -8,7 +8,7 @@ #include "tie.hpp" #include "compat/run-in-thread.hpp" -#include "compat/macros.hpp" +#include "compat/macros.h" #include "value-traits.hpp" @@ -28,8 +28,12 @@ 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); + auto set_current_text = [cb, &v](const QString& str) { + cb->setCurrentText(str); + v = cb->currentText(); + }; + value_::connect(cb, &QComboBox::currentTextChanged, &v, v.value_changed<QString>(), v.DIRECT_CONNTYPE); + value_::connect(&v, v.value_changed<QString>(), cb, set_current_text, v.SAFE_CONNTYPE); } void tie_setting(value<QVariant>& v, QComboBox* cb) @@ -39,13 +43,10 @@ void tie_setting(value<QVariant>& v, QComboBox* cb) int idx = -1; for (int k = 0; k < sz; k++) - { - if (cb->itemData(k) == var) - { + if (cb->itemData(k) == var) { idx = k; break; } - } cb->setCurrentIndex(idx); return idx; }; @@ -58,16 +59,11 @@ void tie_setting(value<QVariant>& v, QComboBox* cb) v = {}; value_::connect(cb, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - &v, [cb, &v](int idx) { - v = cb->itemData(idx); - }, v.DIRECT_CONNTYPE); + &v, [cb, &v](int idx) { v = cb->itemData(idx); }, + v.DIRECT_CONNTYPE); value_::connect(&v, value_::value_changed<QVariant>(), - cb, - [cb, set_idx](const QVariant& var) { - run_in_thread_sync(cb, [&] { - set_idx(var); - }); - }, v.DIRECT_CONNTYPE); + cb, [set_idx](const QVariant& var) { set_idx(var); }, + v.SAFE_CONNTYPE); } void tie_setting(value<bool>& v, QRadioButton* cb) @@ -128,10 +124,7 @@ 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) + value_::connect(w, &QSlider::valueChanged, &v, [=, &v](int pos) { run_in_thread_sync(w, [&]() { |