diff options
author | Stanisław Halik <sthalik@misaki.pl> | 2017-05-14 16:22:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-14 16:22:09 +0200 |
commit | 5c23666b58bb1dd4aea15c0d62a2f716d5be7f52 (patch) | |
tree | e6497e9b55c073be209ec673ef05e62bf57a2c8f /options/tie.hpp | |
parent | 4701dd3b0c8323a11cf7d5ad09c579a9864a41bd (diff) | |
parent | c392181211b245e74292424500265323c960c1aa (diff) |
Merge branch 'unstable' into unstable
Diffstat (limited to 'options/tie.hpp')
-rw-r--r-- | options/tie.hpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/options/tie.hpp b/options/tie.hpp index a3b5a19f..94fe5d49 100644 --- a/options/tie.hpp +++ b/options/tie.hpp @@ -58,6 +58,23 @@ void tie_setting(value<t>& v, QLabel* lb, const QString& format, const xs&... ar v.SAFE_CONNTYPE); } +// Clang 3.9 has a bug +// error: missing default argument on parameter 'args' + +// cf. http://stackoverflow.com/questions/29098835/can-parameter-pack-function-arguments-be-defaulted + +template<typename t, typename F, typename... xs> +decltype((void)((std::declval<F>())(std::declval<const t&>()))) +tie_setting(value<t>& v, QLabel* lb, F&& fun, const QString& fmt = QStringLiteral("%1"), const xs&... args) +{ + auto closure = [=](const t& x) { lb->setText(fmt.arg(fun(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); |