Number of auto scan loops page in MVP 42/208042/4
authorMaria Bialota <m.bialota@samsung.com>
Fri, 7 Jun 2019 15:18:18 +0000 (17:18 +0200)
committerLukasz Wlazly <l.wlazly@partner.samsung.com>
Tue, 18 Jun 2019 11:17:35 +0000 (13:17 +0200)
Change-Id: I8aa5d92b2431c37715a15159b639d335c2d215aa

src/model/NumberOfAutoScanLoopsModel.cpp [new file with mode: 0644]
src/model/NumberOfAutoScanLoopsModel.hpp [new file with mode: 0644]
src/presenter/NumberOfAutoScanLoopsPresenter.cpp [new file with mode: 0644]
src/presenter/NumberOfAutoScanLoopsPresenter.hpp [new file with mode: 0644]
src/presenter/UniversalSwitchSettingsPagePresenter.cpp
src/utils/UniversalSwitchConstants.hpp

diff --git a/src/model/NumberOfAutoScanLoopsModel.cpp b/src/model/NumberOfAutoScanLoopsModel.cpp
new file mode 100644 (file)
index 0000000..6957cdc
--- /dev/null
@@ -0,0 +1,14 @@
+#include "NumberOfAutoScanLoopsModel.hpp"
+#include "Singleton.hpp"
+#include "UniversalSwitchConstants.hpp"
+
+NumberOfAutoScanLoopsModel::NumberOfAutoScanLoopsModel()
+{
+       valueHandle_ = Singleton<VConfInterface>::instance().registerAndGet<int>(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_NUM_OF_SCANS, defaultValue_, [this](auto val) {
+               this->value_ = val;
+       });
+
+       value_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_NUM_OF_SCANS, val);
+       });
+}
diff --git a/src/model/NumberOfAutoScanLoopsModel.hpp b/src/model/NumberOfAutoScanLoopsModel.hpp
new file mode 100644 (file)
index 0000000..9314ace
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef NUMBER_OF_AUTO_SCAN_LOOPS_MODEL_HPP_
+#define NUMBER_OF_AUTO_SCAN_LOOPS_MODEL_HPP_
+
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+#include "utils.hpp"
+#include "UniversalSwitchConstants.hpp"
+
+class NumberOfAutoScanLoopsModel
+{
+       public:
+       NumberOfAutoScanLoopsModel();
+       ObservableProperty<int> value_;
+
+       const utils::Range<double> range_ = {RANGE_MIN_SCANS_NUM, RANGE_MAX_SCANS_NUM};
+       const double step_ = STEP_SCANS_NUM;
+       const double defaultValue_ = DEFAULT_AUTO_SCAN_NUMBER;
+       const bool editable_ = true;
+
+       private:
+       VConfInterface::CallbackHandle valueHandle_;
+
+};
+
+#endif
diff --git a/src/presenter/NumberOfAutoScanLoopsPresenter.cpp b/src/presenter/NumberOfAutoScanLoopsPresenter.cpp
new file mode 100644 (file)
index 0000000..45a28b5
--- /dev/null
@@ -0,0 +1,37 @@
+#include "NumberOfAutoScanLoopsPresenter.hpp"
+
+NumberOfAutoScanLoopsPresenter::NumberOfAutoScanLoopsPresenter()
+       : SpinnerPresenter("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_SCANNING_NUM_OF_SCANS")
+{
+       value_ = model_.value_.value();
+       value_.attach([this](auto val) {
+               model_.value_ = val;
+       });
+
+
+}
+
+utils::Range<double> NumberOfAutoScanLoopsPresenter::getRange()
+{
+       return model_.range_;
+}
+
+bool NumberOfAutoScanLoopsPresenter::isEditable()
+{
+       return model_.editable_;
+}
+
+double NumberOfAutoScanLoopsPresenter::getStep()
+{
+       return model_.step_;
+}
+
+std::string NumberOfAutoScanLoopsPresenter::getFormat()
+{
+       return "%d times";
+}
+
+std::string NumberOfAutoScanLoopsPresenter::getLabel()
+{
+       return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SET_VALUE_DESC_NUM_OF_SCANS";
+}
diff --git a/src/presenter/NumberOfAutoScanLoopsPresenter.hpp b/src/presenter/NumberOfAutoScanLoopsPresenter.hpp
new file mode 100644 (file)
index 0000000..4b0df8d
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef NUMBER_OF_AUTO_SCAN_LOOPS_PRESENTER_HPP_
+#define NUMBER_OF_AUTO_SCAN_LOOPS_PRESENTER_HPP_
+
+#include "NumberOfAutoScanLoopsModel.hpp"
+#include "SpinnerPresenter.hpp"
+
+class NumberOfAutoScanLoopsPresenter : public SpinnerPresenter
+{
+       public:
+       NumberOfAutoScanLoopsPresenter();
+
+       utils::Range<double> getRange();
+       bool isEditable();
+       double getStep();
+       std::string getFormat();
+       std::string getLabel();
+
+       private:
+       NumberOfAutoScanLoopsModel model_;
+};
+
+#endif
index 3ff5d92..13c3ba9 100644 (file)
@@ -10,6 +10,7 @@
 #include "AutoTapPresenter.hpp"
 #include "AutoMoveIntervalPresenter.hpp"
 #include "VoicePresenter.hpp"
+#include "NumberOfAutoScanLoopsPresenter.hpp"
 
 UniversalSwitchSettingsPagePresenter::UniversalSwitchSettingsPagePresenter()
 {
@@ -72,6 +73,7 @@ void UniversalSwitchSettingsPagePresenter::createScanningGropu()
                std::to_string(model_.autoScanLoopsNumber_.value()),
                [this](auto item) {
                        DEBUG("Scan num");
+                       Singleton<AppContext>::instance().push(std::make_unique<NumberOfAutoScanLoopsPresenter>());
                }));
        item = items.back().get();
        model_.autoScanLoopsNumber_.attach([item](auto value) {
@@ -359,4 +361,4 @@ std::string UniversalSwitchSettingsPagePresenter::getColorText(Color color)
                return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_GRAY";
 
        return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_UNDEFINED";
-}
\ No newline at end of file
+}
index b7688d4..4490c55 100644 (file)
 #define DEFAULT_FEEDBACK_VOICE_SPEECH_RATE 0.5
 #define DEFAULT_FEEDBACK_VOICE_SPEECH_VOLUME 0.5
 
+#define RANGE_MIN_SCANS_NUM 1
+#define RANGE_MAX_SCANS_NUM 10
+
+#define STEP_SCANS_NUM 1
+
 #define BUS "org.tizen.UniversalSwitch"
 #define PATH "/org/tizen/UniversalSwitch"
 #define IFACE "org.tizen.UniversalSwitch"
 
-#endif
\ No newline at end of file
+#endif