summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
Diffstat (limited to 'options')
-rw-r--r--options/options.hpp2
-rw-r--r--options/tie.cpp2
-rw-r--r--options/tie.hpp11
3 files changed, 13 insertions, 2 deletions
diff --git a/options/options.hpp b/options/options.hpp
index c1eed97c..0528b0d9 100644
--- a/options/options.hpp
+++ b/options/options.hpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2016 Stanislaw Halik
+/* Copyright (c) 2013-2017 Stanislaw Halik
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
diff --git a/options/tie.cpp b/options/tie.cpp
index ce0e5a35..934871a9 100644
--- a/options/tie.cpp
+++ b/options/tie.cpp
@@ -103,7 +103,7 @@ OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QLineEdit* le)
OTR_OPTIONS_EXPORT void tie_setting(value<QString>& v, QLabel* lb)
{
lb->setText(v);
- base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.DIRECT_CONNTYPE);
+ base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.SAFE_CONNTYPE);
}
OTR_OPTIONS_EXPORT void tie_setting(value<int>& v, QTabWidget* t)
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);