TapDuration page in MVP 33/207533/6
authorTomasz Fejcak <t.fejcak@partner.samsung.com>
Thu, 6 Jun 2019 12:14:36 +0000 (14:14 +0200)
committerLukasz Wlazly <l.wlazly@partner.samsung.com>
Tue, 18 Jun 2019 08:06:04 +0000 (10:06 +0200)
Change-Id: I1a1e98a5e015cd75066f4b7ad6e38f685259d335

src/model/TapDurationModel.cpp [new file with mode: 0644]
src/model/TapDurationModel.hpp [new file with mode: 0644]
src/presenter/TapDurationPresenter.cpp [new file with mode: 0644]
src/presenter/TapDurationPresenter.hpp [new file with mode: 0644]
src/presenter/UniversalSwitchSettingsPagePresenter.cpp

diff --git a/src/model/TapDurationModel.cpp b/src/model/TapDurationModel.cpp
new file mode 100644 (file)
index 0000000..f79b29a
--- /dev/null
@@ -0,0 +1,22 @@
+#include "TapDurationModel.hpp"
+
+#include "setting-accessibility.h"
+
+TapDurationModel::TapDurationModel()
+{
+       stateHandle_ = Singleton<VConfInterface>::instance().registerAndGet<bool>(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_TAP_DURATION_STATE, defaultState_, [this](auto val) {
+               this->state_ = val;
+       });
+
+       state_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_TAP_DURATION_STATE, val);
+       });
+
+       valueHandle_ = Singleton<VConfInterface>::instance().registerAndGet<double>(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_TAP_DURATION_VALUE, defaultValue_, [this](auto val) {
+               this->value_ = val;
+       });
+
+       value_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_TAP_DURATION_VALUE, val);
+       });
+}
\ No newline at end of file
diff --git a/src/model/TapDurationModel.hpp b/src/model/TapDurationModel.hpp
new file mode 100644 (file)
index 0000000..4465b00
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef TAP_DURATION_MODEL_HPP_
+#define TAP_DURATION_MODEL_HPP_
+
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+#include "utils.hpp"
+
+class TapDurationModel
+{
+       public:
+       TapDurationModel();
+       ObservableProperty<bool> state_;
+       ObservableProperty<double> value_;
+
+       const utils::Range<double> range_ = {0.5, 5.0};
+
+       const double step_ = 0.1;
+       const double defaultValue_ = 1.0;
+
+       const bool editable_ = true;
+       const bool defaultState_ = false;
+
+       private:
+       VConfInterface::CallbackHandle stateHandle_;
+       VConfInterface::CallbackHandle valueHandle_;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/presenter/TapDurationPresenter.cpp b/src/presenter/TapDurationPresenter.cpp
new file mode 100644 (file)
index 0000000..16303b0
--- /dev/null
@@ -0,0 +1,40 @@
+#include "TapDurationPresenter.hpp"
+
+TapDurationPresenter::TapDurationPresenter()
+       : SpinnerPresenterWithToggle("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_TAP_DURATION")
+{
+       state_ = model_.state_.value();
+       state_.attach([this](auto state) {
+               model_.state_ = state;
+       });
+
+       value_ = model_.value_.value();
+       value_.attach([this](auto val) {
+               model_.value_ = val;
+       });
+}
+
+utils::Range<double> TapDurationPresenter::getRange()
+{
+       return model_.range_;
+}
+
+bool TapDurationPresenter::isEditable()
+{
+       return model_.editable_;
+}
+
+double TapDurationPresenter::getStep()
+{
+       return model_.step_;
+}
+
+std::string TapDurationPresenter::getFormat()
+{
+       return "%1.1f seconds";
+}
+
+std::string TapDurationPresenter::getLabel()
+{
+       return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_TAP_DURATION";
+}
\ No newline at end of file
diff --git a/src/presenter/TapDurationPresenter.hpp b/src/presenter/TapDurationPresenter.hpp
new file mode 100644 (file)
index 0000000..d8698ee
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef TAP_DURATION_PRESENTER_HPP_
+#define TAP_DURATION_PRESENTER_HPP_
+
+#include "SpinnerPresenterWithToggle.hpp"
+#include "TapDurationModel.hpp"
+
+class TapDurationPresenter : public SpinnerPresenterWithToggle
+{
+       public:
+       TapDurationPresenter();
+
+       utils::Range<double> getRange() override;
+       double getStep() override;
+       bool isEditable() override;
+       std::string getLabel() override;
+       std::string getFormat() override;
+
+       private:
+       TapDurationModel model_;
+};
+#endif
\ No newline at end of file
index 536f4d6..19ac7d6 100644 (file)
@@ -3,6 +3,7 @@
 #include "AutoScanIntervalPresenter.hpp"
 #include "ManageMenuOptionsPagePresenter.hpp"
 #include "PauseOnFirstPresenter.hpp"
+#include "TapDurationPresenter.hpp"
 
 UniversalSwitchSettingsPagePresenter::UniversalSwitchSettingsPagePresenter()
 {
@@ -140,6 +141,7 @@ void UniversalSwitchSettingsPagePresenter::createAdditionalSettingsGroup()
                                                                                 : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
                [this](auto item) {
                        DEBUG("tap duration widget");
+                       Singleton<AppContext>::instance().push(std::make_unique<TapDurationPresenter>());
                },
                ListItem::WidgetType::toggle,
                [this](auto item) {