summaryrefslogtreecommitdiffhomepage
path: root/options/tie.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-04-29 16:18:21 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-04-29 16:18:21 +0200
commitc4942d72935cacc150815f2f5221c71fc3f05bc1 (patch)
treec3d910986d8467a2c9e9a5451b7ef05930beeb50 /options/tie.hpp
parentc231d6a2ba35281f57024a195e50db6640a6413d (diff)
options/tie: allow for binding with a format string
Diffstat (limited to 'options/tie.hpp')
-rw-r--r--options/tie.hpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/options/tie.hpp b/options/tie.hpp
index 93004e0f..a3b5a19f 100644
--- a/options/tie.hpp
+++ b/options/tie.hpp
@@ -47,6 +47,17 @@ tie_setting(value<t>& v, QComboBox* cb)
v.SAFE_CONNTYPE);
}
+template<typename t, typename... xs>
+void tie_setting(value<t>& v, QLabel* lb, const QString& format, const xs&... args)
+{
+ auto closure = [=](const t& x) { lb->setText(format.arg(x, args...)); };
+
+ closure(v());
+ base_value::connect(&v, static_cast<void(base_value::*)(const t&) const>(&base_value::valueChanged),
+ lb, closure,
+ v.SAFE_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);