diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-05-06 13:25:07 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-05-10 11:19:22 +0200 |
commit | dd83dc780bd1232444b6051aff5698f63cd4d741 (patch) | |
tree | c6c29c82a9bd5a996c69cd5cf59340f0990d3d81 /filter-ewma2 | |
parent | 03c5a15199b34b564314ac222d51ab687fc97a93 (diff) |
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
Diffstat (limited to 'filter-ewma2')
-rw-r--r-- | filter-ewma2/ftnoir_ewma_filtercontrols.ui | 18 | ||||
-rw-r--r-- | filter-ewma2/ftnoir_filter_ewma2.h | 2 | ||||
-rw-r--r-- | filter-ewma2/ftnoir_filter_ewma2_dialog.cpp | 26 |
3 files changed, 23 insertions, 23 deletions
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 @@ <string>EWMA filter settings</string> </property> <property name="windowIcon"> - <iconset resource="../gui/ui-res.qrc"> + <iconset resource="../gui/opentrack-res.qrc"> <normaloff>:/images/filter-16.png</normaloff>:/images/filter-16.png</iconset> </property> <property name="layoutDirection"> @@ -73,7 +73,7 @@ <number>0</number> </property> <property name="maximum"> - <number>1000</number> + <number>990</number> </property> <property name="singleStep"> <number>5</number> @@ -82,7 +82,7 @@ <number>50</number> </property> <property name="value"> - <number>1000</number> + <number>990</number> </property> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -123,10 +123,10 @@ </sizepolicy> </property> <property name="minimum"> - <number>1</number> + <number>0</number> </property> <property name="maximum"> - <number>1000</number> + <number>990</number> </property> <property name="singleStep"> <number>5</number> @@ -135,7 +135,7 @@ <number>50</number> </property> <property name="value"> - <number>1000</number> + <number>980</number> </property> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -173,7 +173,7 @@ <number>0</number> </property> <property name="maximum"> - <number>1000</number> + <number>2450</number> </property> <property name="singleStep"> <number>5</number> @@ -182,7 +182,7 @@ <number>50</number> </property> <property name="value"> - <number>1000</number> + <number>490</number> </property> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -287,7 +287,7 @@ p, li { white-space: pre-wrap; } </layout> </widget> <resources> - <include location="../gui/ui-res.qrc"/> + <include location="../gui/opentrack-res.qrc"/> </resources> <connections/> <slots> 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 <cmath> + #include <QDebug> #include <QString> + #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<slider_value>(s.kSmoothingScaleCurve).cur() * 100, 'f', 2) + "%"); - ui.min_label->setText(QString::number(static_cast<slider_value>(s.kMinSmoothing).cur() * 100, 'f', 2) + "%"); - ui.max_label->setText(QString::number(static_cast<slider_value>(s.kMaxSmoothing).cur() * 100, 'f', 2) + "%"); -} |