Use exisiting models in UniversalSwitchSettingsPagePresenter 00/208200/3
authorLukasz Wlazly <l.wlazly@partner.samsung.com>
Wed, 19 Jun 2019 09:22:27 +0000 (11:22 +0200)
committerLukasz Wlazly <l.wlazly@partner.samsung.com>
Mon, 24 Jun 2019 10:11:02 +0000 (12:11 +0200)
Change-Id: I1aad51898b90de19d6e505cc58d758d6d3d2ec76

src/model/AutoScanIntervalModel.cpp [deleted file]
src/model/AutoScanIntervalModel.hpp [deleted file]
src/model/AutoScanModel.cpp [new file with mode: 0644]
src/model/AutoScanModel.hpp [new file with mode: 0644]
src/model/UniversalSwitchSettingsPageModel.cpp
src/model/UniversalSwitchSettingsPageModel.hpp
src/presenter/AutoScanIntervalPresenter.cpp
src/presenter/AutoScanIntervalPresenter.hpp
src/presenter/UniversalSwitchSettingsPagePresenter.cpp
src/presenter/UniversalSwitchSettingsPagePresenter.hpp
src/utils/utils.hpp

diff --git a/src/model/AutoScanIntervalModel.cpp b/src/model/AutoScanIntervalModel.cpp
deleted file mode 100644 (file)
index 21e444b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "AutoScanIntervalModel.hpp"
-
-#include "Singleton.hpp"
-
-AutoScanIntervalModel::AutoScanIntervalModel()
-{
-       autoScanIntervalValueHandle_ = Singleton<VConfInterface>::instance().registerAndGet<double>("db/setting/accessibility/universal-switch/AUTO_SCAN_INTERVAL", 1, [this](auto val) {
-               this->autoScanIntervalValue_ = val;
-       });
-
-       autoScanIntervalValue_.attach([](auto val) {
-               Singleton<VConfInterface>::instance().set("db/setting/accessibility/universal-switch/AUTO_SCAN_INTERVAL", val);
-       });
-}
\ No newline at end of file
diff --git a/src/model/AutoScanIntervalModel.hpp b/src/model/AutoScanIntervalModel.hpp
deleted file mode 100644 (file)
index 85b5312..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef AUTO_SCAN_INTERVAL_MODEL_HPP
-#define AUTO_SCAN_INTERVAL_MODEL_HPP
-
-#include "ObservableProperty.hpp"
-#include "VConf.hpp"
-#include "utils.hpp"
-
-class AutoScanIntervalModel
-{
-       public:
-       AutoScanIntervalModel();
-       ObservableProperty<double> autoScanIntervalValue_;
-
-       const utils::Range<double> range_ = {0.5, 9.9};
-       const double step_ = 0.1;
-
-       private:
-       VConfInterface::CallbackHandle autoScanIntervalValueHandle_;
-};
-
-#endif
\ No newline at end of file
diff --git a/src/model/AutoScanModel.cpp b/src/model/AutoScanModel.cpp
new file mode 100644 (file)
index 0000000..7e14210
--- /dev/null
@@ -0,0 +1,22 @@
+#include "AutoScanModel.hpp"
+
+#include "Singleton.hpp"
+
+AutoScanModel::AutoScanModel()
+{
+       enabledHandle_ = Singleton<VConfInterface>::instance().registerAndGet<double>("db/setting/accessibility/universal-switch/AUTO_SCAN_ENABLED", 1, [this](auto val) {
+               this->enabled_ = val;
+       });
+
+       enabled_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set("db/setting/accessibility/universal-switch/AUTO_SCAN_ENABLED", val);
+       });
+
+       intervalHandle_ = Singleton<VConfInterface>::instance().registerAndGet<double>("db/setting/accessibility/universal-switch/AUTO_SCAN_INTERVAL", 1, [this](auto val) {
+               this->interval_ = val;
+       });
+
+       interval_.attach([](auto val) {
+               Singleton<VConfInterface>::instance().set("db/setting/accessibility/universal-switch/AUTO_SCAN_INTERVAL", val);
+       });
+}
\ No newline at end of file
diff --git a/src/model/AutoScanModel.hpp b/src/model/AutoScanModel.hpp
new file mode 100644 (file)
index 0000000..54f4a5a
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef AUTO_SCAN_MODEL_HPP
+#define AUTO_SCAN_MODEL_HPP
+
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+#include "utils.hpp"
+
+class AutoScanModel
+{
+       public:
+       AutoScanModel();
+       ObservableProperty<bool> enabled_;
+       ObservableProperty<double> interval_;
+
+       const utils::Range<double> range_ = {0.5, 9.9};
+       const double step_ = 0.1;
+
+       private:
+       VConfInterface::CallbackHandle enabledHandle_;
+       VConfInterface::CallbackHandle intervalHandle_;
+};
+
+#endif
\ No newline at end of file
index cc75da4d45111ea1f8a795e5df4642c355601a22..40f32318d81f68f4e5b88e657ab4d82844a8d3bf 100644 (file)
@@ -4,23 +4,8 @@
 
 UniversalSwitchSettingsPageModel::UniversalSwitchSettingsPageModel()
 {
-       synchronizePropertyWithVConf(autoScanState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_SCAN_ENABLED, DEFAULT_AUTO_SCAN_STATE);
-       synchronizePropertyWithVConf(autoScanInterval_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_SCAN_INT, DEFAULT_AUTO_SCAN_INTERVAL);
-       synchronizePropertyWithVConf(autoScanInterval_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_SCAN_INT, DEFAULT_AUTO_SCAN_INTERVAL);
-       synchronizePropertyWithVConf(autoScanLoopsNumber_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_NUM_OF_SCANS, DEFAULT_AUTO_SCAN_NUMBER);
        synchronizePropertyWithVConf(scanMethod_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SCAN_METHOD, DEFAULT_SCAN_METHOD);
        synchronizePropertyWithVConf(scanDirection_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SCAN_DIR_VERTICAL, DEFAULT_SCAN_DIR);
-       synchronizePropertyWithVConf(pointScanSpeed_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SCAN_PT_SPEED, DEFAULT_SCAN_PT_SPEED);
-       synchronizePropertyWithVConf(pauseOnFirstState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_PAUSE_ON_FIRST_STATE, DEFAULT_PAUSE_ON_FIRST_STATE);
-       synchronizePropertyWithVConf(pauseOnFirstTime_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_PAUSE_ON_FIRST_VALUE, DEFAULT_PAUSE_ON_FIRST_VALUE);
-       synchronizePropertyWithVConf(tapDurationState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_TAP_DURATION_STATE, DEFAULT_TAP_DURATION_STATE);
-       synchronizePropertyWithVConf(tapDurationValue_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_TAP_DURATION_VALUE, DEFAULT_TAP_DURATION_VALUE);
-       synchronizePropertyWithVConf(singleInteractionIntervalState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SGL_IACTION_INT_STATE, DEFAULT_SGL_IACTION_INT_STATE);
-       synchronizePropertyWithVConf(singleInteractionIntervalValue_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SGL_IACTION_INT_VALUE, DEFAULT_SGL_IACTION_INT_VALUE);
-       synchronizePropertyWithVConf(autoTapState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_TAP_STATE, DEFAULT_AUTO_TAP_STATE);
-       synchronizePropertyWithVConf(autoTapValue_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_TAP_VALUE, DEFAULT_AUTO_TAP_VALUE);
-       synchronizePropertyWithVConf(autoMoveState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_MOVE_INT_STATE, DEFAULT_AUTO_MOVE_INT_STATE);
-       synchronizePropertyWithVConf(autoMoveValue_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_MOVE_INT_VALUE, DEFAULT_AUTO_MOVE_INT_VALUE);
        synchronizePropertyWithVConf(autoTapKeyboardState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_TAP_KBD_STATE, DEFAULT_AUTO_TAP_KEYBOARD_STATE);
 
        vconfHandles_.push_back(Singleton<VConfInterface>::instance().registerAndGet<int>(
@@ -34,9 +19,6 @@ UniversalSwitchSettingsPageModel::UniversalSwitchSettingsPageModel()
                Singleton<VConfInterface>::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_FEEDBACK_CURSOR_COLOR, newValue.toABGRInt());
        });
 
-       synchronizePropertyWithVConf(feedbackSoundState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_FEEDBACK_SOUND_STATE, DEFAULT_FEEDBACK_SOUND_STATE);
-       synchronizePropertyWithVConf(feedbackVoiceState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_FEEDBACK_VOICE_STATE, DEFAULT_FEEDBACK_VOICE_STATE);
-
        connectionPtr_ = DBus::getDBusConnectionByType(DBus::ConnectionType::SESSION);
        dBusClient_ = DBus::DBusClient{BUS, PATH, IFACE, connectionPtr_};
        auto reply = dBusClient_.method<DBus::ValueOrError<std::vector<std::tuple<std::string, std::string, std::string, int32_t>>>()>("getAllSwitchConfigurationItems").call();
index bd6abf800f7222141acddf9718ec593f5a14a2a6..da4a228bcda95f68c3f5a40c5e4130a68f6db0c5 100644 (file)
@@ -6,17 +6,6 @@
 #include "ObservableProperty.hpp"
 #include "ScanningProperties.hpp"
 #include "VConf.hpp"
-// enum class ScanMethod
-// {
-//     POINT = 1,
-//     ROW
-// };
-
-// enum class ScanDirection
-// {
-//     TO_BOTTOM = 1,
-//     TO_TOP
-// };
 
 class UniversalSwitchSettingsPageModel
 {
@@ -25,36 +14,12 @@ class UniversalSwitchSettingsPageModel
 
        ObservableProperty<int> configuredSwitchesCount_;
 
-       ObservableProperty<bool> autoScanState_;
-       ObservableProperty<double> autoScanInterval_;
-       ObservableProperty<int> autoScanLoopsNumber_;
-
        ObservableProperty<ScanMethod> scanMethod_;
        ObservableProperty<ScanDirection> scanDirection_;
-       ObservableProperty<int> pointScanSpeed_;
-
-       ObservableProperty<bool> pauseOnFirstState_;
-       ObservableProperty<double> pauseOnFirstTime_;
-
-       ObservableProperty<bool> tapDurationState_;
-       ObservableProperty<double> tapDurationValue_;
-
-       ObservableProperty<bool> singleInteractionIntervalState_;
-       ObservableProperty<double> singleInteractionIntervalValue_;
-
-       ObservableProperty<bool> autoTapState_;
-       ObservableProperty<double> autoTapValue_;
-
-       ObservableProperty<bool> autoMoveState_;
-       ObservableProperty<double> autoMoveValue_;
-
        ObservableProperty<bool> autoTapKeyboardState_;
 
        ObservableProperty<Color> cursorColor_;
 
-       ObservableProperty<bool> feedbackSoundState_;
-       ObservableProperty<bool> feedbackVoiceState_;
-
        private:
        template <typename T>
        void synchronizePropertyWithVConf(ObservableProperty<T> &property, const std::string &vconfKey, T defaultValue)
index 20bebd6fb7d90b8fdfc30f57eabe870f2d0da2d8..d0e0ae0aa6538ef9e455e64f62f407b0c0ecda8e 100644 (file)
@@ -3,9 +3,9 @@
 AutoScanIntervalPresenter::AutoScanIntervalPresenter()
        : SpinnerPresenter("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_SCANNING_AUTO_SCAN_INT")
 {
-       value_ = model_.autoScanIntervalValue_;
+       value_ = model_.interval_;
        value_.attach([this](auto val) {
-               model_.autoScanIntervalValue_ = val;
+               model_.interval_ = val;
        });
 }
 
index 19ce5126bb76b742e9696d24946b7b6b888546a9..0677b9e82f015e07066e8bafd6ae7acdf351f94e 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef AUTO_SCAN_INTERVAL_PRESENTER
 #define AUTO_SCAN_INTERVAL_PRESENTER
 
-#include "AutoScanIntervalModel.hpp"
+#include "AutoScanModel.hpp"
 #include "SpinnerPresenter.hpp"
 
 class AutoScanIntervalPresenter : public SpinnerPresenter
@@ -14,7 +14,7 @@ class AutoScanIntervalPresenter : public SpinnerPresenter
        std::string getFormat() override;
 
        private:
-       AutoScanIntervalModel model_;
+       AutoScanModel model_;
 };
 
 #endif
\ No newline at end of file
index 625c0b87f16d02961ec17458bfccb665eb54e5a6..491a79e6685e3d3b3fd2c54c627d979db2be2cdb 100644 (file)
@@ -1,21 +1,17 @@
 #include "UniversalSwitchSettingsPagePresenter.hpp"
 
-#include "AutoMoveIntervalPresenter.hpp"
-#include "AutoScanIntervalPresenter.hpp"
-#include "AutoTapPresenter.hpp"
 #include "AppContext.hpp"
+#include "AutoMoveIntervalPresenter.hpp"
 #include "AutoScanIntervalPresenter.hpp"
 #include "AutoTapPresenter.hpp"
 #include "ManageMenuOptionsPagePresenter.hpp"
 #include "NumberOfAutoScanLoopsPresenter.hpp"
 #include "PauseOnFirstPresenter.hpp"
 #include "PointScanSpeedPresenter.hpp"
+#include "SingleInteractionIntervalPresenter.hpp"
 #include "SoundPresenter.hpp"
 #include "TapDurationPresenter.hpp"
-#include "AutoMoveIntervalPresenter.hpp"
 #include "VoicePresenter.hpp"
-#include "SingleInteractionIntervalPresenter.hpp"
-#include "TapDurationPresenter.hpp"
 
 UniversalSwitchSettingsPagePresenter::UniversalSwitchSettingsPagePresenter()
 {
@@ -54,33 +50,33 @@ void UniversalSwitchSettingsPagePresenter::createScanningGropu()
                ListItem::WidgetType::toggle,
                std::function<void(ListItem * item)>{},
                std::function<void(ListItem * item)>{},
-               model_.autoScanState_.value()));
+               autoScanModel_.enabled_.value()));
        auto item = items.back().get();
-       model_.autoScanState_.attach([item](auto value) {
+       autoScanModel_.enabled_.attach([item](auto value) {
                item->widgetState_ = value;
        });
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_SCANNING_AUTO_SCAN_INT"},
-               TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.autoScanInterval_.value()).str(),
+               TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", autoScanModel_.interval_.value()).str(),
                [this](auto item) {
                        DEBUG("Auto scan interval");
                        Singleton<AppContext>::instance().push(std::make_unique<AutoScanIntervalPresenter>());
                }));
        item = items.back().get();
-       model_.autoScanInterval_.attach([item](auto value) {
+       autoScanModel_.interval_.attach([item](auto value) {
                item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", value).str();
        });
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_SCANNING_NUM_OF_SCANS"},
-               std::to_string(model_.autoScanLoopsNumber_.value()),
+               std::to_string(autoScanLoopsModel_.value_.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) {
+       autoScanLoopsModel_.value_.attach([item](auto value) {
                item->description_ = std::to_string(value);
        });
 
@@ -108,13 +104,13 @@ void UniversalSwitchSettingsPagePresenter::createScanningGropu()
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_SCANNING_PT_SPEED"},
-               std::to_string(model_.pointScanSpeed_.value()),
+               std::to_string(pointScanSpeedModel_.value_.value()),
                [this](auto item) {
                        DEBUG("Scan point speed");
                        Singleton<AppContext>::instance().push(std::make_unique<PointScanSpeedPresenter>());
                }));
        item = items.back().get();
-       model_.pointScanSpeed_.attach([item](auto value) {
+       pointScanSpeedModel_.value_.attach([item](auto value) {
                item->description_ = std::to_string(value);
        });
 }
@@ -126,7 +122,7 @@ void UniversalSwitchSettingsPagePresenter::createAdditionalSettingsGroup()
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_PAUSE_ON_FIRST"},
-               model_.pauseOnFirstState_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.pauseOnFirstTime_.value()).str()
+               pauseOnFirstModel_.value_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", pauseOnFirstModel_.value_.value()).str()
                                                                                  : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
                [this](auto item) {
                        DEBUG("Pause on first");
@@ -134,23 +130,23 @@ void UniversalSwitchSettingsPagePresenter::createAdditionalSettingsGroup()
                },
                ListItem::WidgetType::toggle,
                [this](auto item) {
-                       model_.pauseOnFirstState_ = item->widgetState_.value();
+                       pauseOnFirstModel_.state_ = item->widgetState_.value();
                },
                std::function<void(ListItem * item)>{},
-               model_.pauseOnFirstState_.value()));
+               pauseOnFirstModel_.value_.value()));
        auto item = items.back().get();
        auto pauseOnFirstCb = [this, item](auto value) {
-               if (model_.pauseOnFirstState_.value())
-                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.pauseOnFirstTime_.value()).str();
+               if (pauseOnFirstModel_.value_.value())
+                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", pauseOnFirstModel_.value_.value()).str();
                else
                        item->description_ = "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF";
        };
-       model_.pauseOnFirstState_.attach(pauseOnFirstCb);
-       model_.pauseOnFirstTime_.attach(pauseOnFirstCb);
+       pauseOnFirstModel_.state_.attach(pauseOnFirstCb);
+       pauseOnFirstModel_.value_.attach(pauseOnFirstCb);
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_TAP_DURATION"},
-               model_.tapDurationState_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.tapDurationValue_.value()).str()
+               tapDurationModel_.state_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", tapDurationModel_.value_.value()).str()
                                                                                 : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
                [this](auto item) {
                        DEBUG("tap duration widget");
@@ -159,23 +155,23 @@ void UniversalSwitchSettingsPagePresenter::createAdditionalSettingsGroup()
                ListItem::WidgetType::toggle,
                [this](auto item) {
                        DEBUG("tap duration");
-                       model_.tapDurationState_ = item->widgetState_.value();
+                       tapDurationModel_.state_ = item->widgetState_.value();
                },
                std::function<void(ListItem * item)>{},
-               model_.tapDurationState_.value()));
+               tapDurationModel_.state_.value()));
        item = items.back().get();
        auto tapDurationCb = [this, item](auto value) {
-               if (model_.tapDurationState_.value())
-                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.tapDurationValue_.value()).str();
+               if (tapDurationModel_.state_.value())
+                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", tapDurationModel_.value_.value()).str();
                else
                        item->description_ = "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF";
        };
-       model_.tapDurationState_.attach(tapDurationCb);
-       model_.tapDurationValue_.attach(tapDurationCb);
+       tapDurationModel_.state_.attach(tapDurationCb);
+       tapDurationModel_.value_.attach(tapDurationCb);
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_SGL_IACTION_INT"},
-               model_.singleInteractionIntervalState_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.singleInteractionIntervalValue_.value()).str()
+               singleInteractionIntervalModel_.state_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", singleInteractionIntervalModel_.value_.value()).str()
                                                                                                           : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
                [this](auto item) {
                        DEBUG("single interaction interval widget");
@@ -183,23 +179,23 @@ void UniversalSwitchSettingsPagePresenter::createAdditionalSettingsGroup()
                },
                ListItem::WidgetType::toggle,
                [this](auto item) {
-                       model_.singleInteractionIntervalState_ = item->widgetState_.value();
+                       singleInteractionIntervalModel_.state_ = item->widgetState_.value();
                },
                std::function<void(ListItem * item)>{},
-               model_.singleInteractionIntervalState_.value()));
+               singleInteractionIntervalModel_.state_.value()));
        item = items.back().get();
        auto snglIntCb = [this, item](auto value) {
-               if (model_.singleInteractionIntervalState_.value())
-                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.singleInteractionIntervalValue_.value()).str();
+               if (singleInteractionIntervalModel_.state_.value())
+                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", singleInteractionIntervalModel_.value_.value()).str();
                else
                        item->description_ = "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF";
        };
-       model_.singleInteractionIntervalState_.attach(snglIntCb);
-       model_.singleInteractionIntervalValue_.attach(snglIntCb);
+       singleInteractionIntervalModel_.state_.attach(snglIntCb);
+       singleInteractionIntervalModel_.value_.attach(snglIntCb);
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_AUTO_TAP"},
-               model_.autoTapState_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.autoTapValue_.value()).str()
+               autoTapModel_.state_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", autoTapModel_.value_.value()).str()
                                                                         : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
                [this](auto item) {
                        DEBUG("auto tap widget");
@@ -207,45 +203,45 @@ void UniversalSwitchSettingsPagePresenter::createAdditionalSettingsGroup()
                },
                ListItem::WidgetType::toggle,
                [this](auto item) {
-                       model_.autoTapState_ = item->widgetState_.value();
+                       autoTapModel_.state_ = item->widgetState_.value();
                        DEBUG("auto tap");
                },
                std::function<void(ListItem * item)>{},
-               model_.autoTapState_.value()));
+               autoTapModel_.state_.value()));
        item = items.back().get();
        auto autoTapCb = [this, item](auto value) {
-               if (model_.autoTapState_.value())
-                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.autoTapValue_.value()).str();
+               if (autoTapModel_.state_.value())
+                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", autoTapModel_.value_.value()).str();
                else
                        item->description_ = "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF";
        };
-       model_.autoTapState_.attach(autoTapCb);
-       model_.autoTapValue_.attach(autoTapCb);
+       autoTapModel_.state_.attach(autoTapCb);
+       autoTapModel_.value_.attach(autoTapCb);
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_AUTO_MOVE_INT"},
-               model_.autoMoveState_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.autoMoveValue_.value()).str()
-                                                                         : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
+               autoMoveIntervalModel_.state_.value() ? TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", autoMoveIntervalModel_.value_.value()).str()
+                                                                                         : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
                [this](auto item) {
                        DEBUG("auto move widget");
                        Singleton<AppContext>::instance().push(std::make_unique<AutoMoveIntervalPresenter>());
                },
                ListItem::WidgetType::toggle,
                [this](auto item) {
-                       model_.autoMoveState_ = item->widgetState_.value();
+                       autoMoveIntervalModel_.state_ = item->widgetState_.value();
                        DEBUG("auto move");
                },
                std::function<void(ListItem * item)>{},
-               model_.autoMoveState_.value()));
+               autoMoveIntervalModel_.state_.value()));
        item = items.back().get();
        auto autoMoveCb = [this, item](auto value) {
-               if (model_.autoMoveState_.value())
-                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", model_.autoMoveValue_.value()).str();
+               if (autoMoveIntervalModel_.state_.value())
+                       item->description_ = TranslatedString::create("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS", autoMoveIntervalModel_.value_.value()).str();
                else
                        item->description_ = "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF";
        };
-       model_.autoMoveState_.attach(autoMoveCb);
-       model_.autoMoveValue_.attach(autoMoveCb);
+       autoMoveIntervalModel_.state_.attach(autoMoveCb);
+       autoMoveIntervalModel_.value_.attach(autoMoveCb);
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_AUTO_TAP_KBD"},
@@ -281,7 +277,7 @@ void UniversalSwitchSettingsPagePresenter::createFeedbackGroup()
 
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_SOUND"},
-               model_.feedbackSoundState_.value() ? std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_ON"} : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
+               soundModel_.state_.value() ? utils::doubleToPercent(soundModel_.value_.value()) + " of media volume" : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
                [this](auto item) {
                        DEBUG("feedback sound widget");
                        Singleton<AppContext>::instance().push(std::make_unique<SoundPresenter>());
@@ -289,19 +285,23 @@ void UniversalSwitchSettingsPagePresenter::createFeedbackGroup()
                ListItem::WidgetType::toggle,
                [this](auto item) {
                        DEBUG("feedback sound");
-                       model_.feedbackSoundState_ = item->widgetState_.value();
+                       soundModel_.state_ = item->widgetState_.value();
                },
                std::function<void(ListItem * item)>{},
-               model_.feedbackSoundState_.value()));
+               soundModel_.state_.value()));
        item = items.back().get();
-       model_.feedbackSoundState_.attach([item, this](auto value) {
+       soundModel_.state_.attach([item, this](auto value) {
                item->widgetState_ = value;
-               item->description_ = value ? "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_ON" : "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF";
+               item->description_ = value ? utils::doubleToPercent(soundModel_.value_.value()) + " of media volume" : "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF";
        });
 
+       auto speechRate = "Speech rate: " + utils::doubleToString(voiceModel_.rate_.value(), 1);
+       auto mediaVolume = "Speech volume: " + utils::doubleToPercent(voiceModel_.volume_.value()) + " of media volume";
+       auto desc = voiceModel_.state_.value() ? speechRate + "<br>" + mediaVolume : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"};
+
        items.push_back(std::make_unique<ListItem>(
                std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_VOICE"},
-               model_.feedbackVoiceState_.value() ? std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_ON"} : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"},
+               desc,
                [this](auto item) {
                        DEBUG("feedback sound widget");
                        Singleton<AppContext>::instance().push(std::make_unique<VoicePresenter>());
@@ -309,14 +309,17 @@ void UniversalSwitchSettingsPagePresenter::createFeedbackGroup()
                ListItem::WidgetType::toggle,
                [this](auto item) {
                        DEBUG("auto move");
-                       model_.feedbackVoiceState_ = item->widgetState_.value();
+                       voiceModel_.state_ = item->widgetState_.value();
                },
                std::function<void(ListItem * item)>{},
-               model_.feedbackVoiceState_.value()));
+               voiceModel_.state_.value()));
        item = items.back().get();
-       model_.feedbackVoiceState_.attach([item, this](auto value) {
+       voiceModel_.state_.attach([item, this](auto value) {
                item->widgetState_ = value;
-               item->description_ = value ? "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_ON" : "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF";
+               auto speechRate = "Speech rate: " + utils::doubleToString(voiceModel_.rate_.value(), 1);
+               auto mediaVolume = "Speech volume: " + utils::doubleToPercent(voiceModel_.volume_.value()) + " of media volume";
+               auto desc = voiceModel_.state_.value() ? speechRate + "<br>" + mediaVolume : std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF"};
+               item->description_ = desc;
        });
 
        items.push_back(std::make_unique<ListItem>(
index 3837208c3716bc3fe9b5f9dbcb3a666154bcbc99..5f83fe10688f4f284fce893667e17798f70b1ec5 100644 (file)
@@ -1,9 +1,19 @@
 #ifndef UNIVERSAL_SWITCH_SETTINGS_PAGE_PRESENTER_HPP
 #define UNIVERSAL_SWITCH_SETTINGS_PAGE_PRESENTER_HPP
 
+#include "AutoMoveIntervalModel.hpp"
+#include "AutoScanModel.hpp"
+#include "AutoTapModel.hpp"
 #include "ListPresenter.hpp"
+#include "NumberOfAutoScanLoopsModel.hpp"
+#include "PauseOnFirstModel.hpp"
+#include "PointScanSpeedModel.hpp"
+#include "SingleInteractionIntervalModel.hpp"
+#include "SoundModel.hpp"
 #include "SwitchesPage.hpp"
+#include "TapDurationModel.hpp"
 #include "UniversalSwitchSettingsPageModel.hpp"
+#include "VoiceModel.hpp"
 
 class UniversalSwitchSettingsPagePresenter : public ListPresenter
 {
@@ -20,6 +30,17 @@ class UniversalSwitchSettingsPagePresenter : public ListPresenter
        static std::string getColorText(Color color);
 
        UniversalSwitchSettingsPageModel model_;
+       AutoScanModel autoScanModel_;
+       NumberOfAutoScanLoopsModel autoScanLoopsModel_;
+       PointScanSpeedModel pointScanSpeedModel_;
+       PauseOnFirstModel pauseOnFirstModel_;
+       TapDurationModel tapDurationModel_;
+       SingleInteractionIntervalModel singleInteractionIntervalModel_;
+       AutoTapModel autoTapModel_;
+       AutoMoveIntervalModel autoMoveIntervalModel_;
+       SoundModel soundModel_;
+       VoiceModel voiceModel_;
+
        std::unique_ptr<SwitchesPage> switchesPage_;
 };
 
index 4b82f1cd6ec068e4124429629052f168419d75bb..0c9ca9fab3813f24c3519eb320aafd423bf5bf47 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "Elementary.h"
 
+#include <sstream>
+
 using SettingCallback = void (*)(void *, Evas_Object *, void *);
 
 namespace utils
@@ -59,6 +61,21 @@ namespace utils
 
                return rescaledValue;
        }
+
+       inline std::string doubleToPercent(double val)
+       {
+               return std::to_string(static_cast<int>(val * 100)) + "%";
+       }
+
+       inline std::string doubleToString(double val, size_t precision)
+       {
+               std::ostringstream out;
+               out.precision(1);
+
+               out << std::fixed << val;
+
+               return out.str();
+       }
 } // namespace utils
 
 #endif