From dd83dc780bd1232444b6051aff5698f63cd4d741 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 6 May 2017 13:25:07 +0200 Subject: filter/ewma: fix labels - single step is a round value now - use a `tie_setting' overload for formatting the value, rather than a separate slot --- filter-ewma2/ftnoir_ewma_filtercontrols.ui | 18 +++++++++--------- filter-ewma2/ftnoir_filter_ewma2.h | 2 -- filter-ewma2/ftnoir_filter_ewma2_dialog.cpp | 26 ++++++++++++++------------ 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'filter-ewma2') diff --git a/filter-ewma2/ftnoir_ewma_filtercontrols.ui b/filter-ewma2/ftnoir_ewma_filtercontrols.ui index d5cc082e..e0a98174 100644 --- a/filter-ewma2/ftnoir_ewma_filtercontrols.ui +++ b/filter-ewma2/ftnoir_ewma_filtercontrols.ui @@ -23,7 +23,7 @@ EWMA filter settings - + :/images/filter-16.png:/images/filter-16.png @@ -73,7 +73,7 @@ 0 - 1000 + 990 5 @@ -82,7 +82,7 @@ 50 - 1000 + 990 Qt::Horizontal @@ -123,10 +123,10 @@ - 1 + 0 - 1000 + 990 5 @@ -135,7 +135,7 @@ 50 - 1000 + 980 Qt::Horizontal @@ -173,7 +173,7 @@ 0 - 1000 + 2450 5 @@ -182,7 +182,7 @@ 50 - 1000 + 490 Qt::Horizontal @@ -287,7 +287,7 @@ p, li { white-space: pre-wrap; } - + diff --git a/filter-ewma2/ftnoir_filter_ewma2.h b/filter-ewma2/ftnoir_filter_ewma2.h index 8babc540..f8c77280 100644 --- a/filter-ewma2/ftnoir_filter_ewma2.h +++ b/filter-ewma2/ftnoir_filter_ewma2.h @@ -19,7 +19,6 @@ struct settings : opts { {} }; - class ewma : public IFilter { public: @@ -54,7 +53,6 @@ private: private slots: void doOK(); void doCancel(); - void update_labels(int); }; class ewmaDll : public Metadata diff --git a/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp b/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp index ad07737b..55e9782e 100644 --- a/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -1,7 +1,10 @@ #include "ftnoir_filter_ewma2.h" + #include + #include #include + #include "api/plugin-api.hpp" #include "ui_ftnoir_ewma_filtercontrols.h" @@ -16,17 +19,23 @@ dialog_ewma::dialog_ewma() tie_setting(s.kMinSmoothing, ui.minSmooth); tie_setting(s.kSmoothingScaleCurve, ui.powCurve); - connect(ui.powCurve, &QSlider::valueChanged, this, &dialog_ewma::update_labels); - connect(ui.minSmooth, &QSlider::valueChanged, this, &dialog_ewma::update_labels); - connect(ui.maxSmooth, &QSlider::valueChanged, this, &dialog_ewma::update_labels); + tie_setting(s.kSmoothingScaleCurve, ui.curve_label, + [](auto& x) { return x * 100; }, + "%1%", 0, 'f', 2); + + tie_setting(s.kMinSmoothing, ui.min_label, + [](auto& x) { return x * 100; }, + "%1%", 0, 'f', 2); + + tie_setting(s.kMaxSmoothing, ui.max_label, + [](auto& x) { return x * 100; }, + "%1%", 0, 'f', 2); connect(ui.minSmooth, &QSlider::valueChanged, this, [&](int v) -> void { if (ui.maxSmooth->value() < v) ui.maxSmooth->setValue(v); }); connect(ui.maxSmooth, &QSlider::valueChanged, this, [&](int v) -> void { if (ui.minSmooth->value() > v) ui.minSmooth->setValue(v); }); - - update_labels(0); } void dialog_ewma::doOK() @@ -39,10 +48,3 @@ void dialog_ewma::doCancel() { close(); } - -void dialog_ewma::update_labels(int) -{ - ui.curve_label->setText(QString::number(static_cast(s.kSmoothingScaleCurve).cur() * 100, 'f', 2) + "%"); - ui.min_label->setText(QString::number(static_cast(s.kMinSmoothing).cur() * 100, 'f', 2) + "%"); - ui.max_label->setText(QString::number(static_cast(s.kMaxSmoothing).cur() * 100, 'f', 2) + "%"); -} -- cgit v1.2.3