From: Oskar Chodowicz Date: Thu, 30 May 2019 07:00:16 +0000 (+0200) Subject: Cursor color page in MVP X-Git-Tag: accepted/tizen/unified/20190705.110821~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=697a015e6aec16ed39ff59eaff83235fc3994f3a;p=profile%2Fmobile%2Fapps%2Fnative%2Faccessibility-setting.git Cursor color page in MVP Change-Id: I4dc6f95bd2809990b63f6943d146b7a66ad7259d --- diff --git a/src/model/CursorColorModel.cpp b/src/model/CursorColorModel.cpp new file mode 100644 index 0000000..383234e --- /dev/null +++ b/src/model/CursorColorModel.cpp @@ -0,0 +1,34 @@ +#include "CursorColorModel.hpp" + +#include "UniversalSwitchConstants.hpp" + +CursorColorModel::CursorColorModel() +{ + vconfHandle_ = Singleton::instance().registerAndGet( + VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_FEEDBACK_CURSOR_COLOR, + DEFAULT_FEEDBACK_CURSOR_COLOR, + [this](auto value) { + this->cursorColor_ = Color::fromABGR(value); + }); + cursorColor_.attach([this](auto value) { + Singleton::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_FEEDBACK_CURSOR_COLOR, value.toABGRInt()); + }); +} + +std::string CursorColorModel::getColorText(Color color) +{ + if (color == Color::RED) + return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_RED"; + if (color == Color::ORANGE) + return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_ORANGE"; + if (color == Color::YELLOW) + return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_YELLOW"; + if (color == Color::GREEN) + return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_GREEN"; + if (color == Color::BLUE) + return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_BLUE"; + if (color == Color::GRAY) + return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_GRAY"; + + return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_UNDEFINED"; +} \ No newline at end of file diff --git a/src/model/CursorColorModel.hpp b/src/model/CursorColorModel.hpp new file mode 100644 index 0000000..58c0a2a --- /dev/null +++ b/src/model/CursorColorModel.hpp @@ -0,0 +1,19 @@ +#ifndef CURSOR_COLOR_MODEL_HPP +#define CURSOR_COLOR_MODEL_HPP + +#include "Geometry.hpp" +#include "ObservableProperty.hpp" +#include "VConf.hpp" + +class CursorColorModel +{ + public: + CursorColorModel(); + ObservableProperty cursorColor_; + std::string getColorText(Color color); + + private: + VConfInterface::CallbackHandle vconfHandle_; +}; + +#endif \ No newline at end of file diff --git a/src/model/UniversalSwitchSettingsPageModel.cpp b/src/model/UniversalSwitchSettingsPageModel.cpp index 40f3231..9625a59 100644 --- a/src/model/UniversalSwitchSettingsPageModel.cpp +++ b/src/model/UniversalSwitchSettingsPageModel.cpp @@ -8,17 +8,6 @@ UniversalSwitchSettingsPageModel::UniversalSwitchSettingsPageModel() synchronizePropertyWithVConf(scanDirection_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SCAN_DIR_VERTICAL, DEFAULT_SCAN_DIR); synchronizePropertyWithVConf(autoTapKeyboardState_, VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_TAP_KBD_STATE, DEFAULT_AUTO_TAP_KEYBOARD_STATE); - vconfHandles_.push_back(Singleton::instance().registerAndGet( - VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_FEEDBACK_CURSOR_COLOR, - DEFAULT_FEEDBACK_CURSOR_COLOR, - [this](auto value) { - cursorColor_ = Color::fromABGR(value); - })); - - cursorColor_.attach([this](auto newValue) { - Singleton::instance().set(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_FEEDBACK_CURSOR_COLOR, newValue.toABGRInt()); - }); - connectionPtr_ = DBus::getDBusConnectionByType(DBus::ConnectionType::SESSION); dBusClient_ = DBus::DBusClient{BUS, PATH, IFACE, connectionPtr_}; auto reply = dBusClient_.method>>()>("getAllSwitchConfigurationItems").call(); diff --git a/src/model/UniversalSwitchSettingsPageModel.hpp b/src/model/UniversalSwitchSettingsPageModel.hpp index da4a228..1024df1 100644 --- a/src/model/UniversalSwitchSettingsPageModel.hpp +++ b/src/model/UniversalSwitchSettingsPageModel.hpp @@ -18,8 +18,6 @@ class UniversalSwitchSettingsPageModel ObservableProperty scanDirection_; ObservableProperty autoTapKeyboardState_; - ObservableProperty cursorColor_; - private: template void synchronizePropertyWithVConf(ObservableProperty &property, const std::string &vconfKey, T defaultValue) diff --git a/src/presenter/CursorColorPagePresenter.cpp b/src/presenter/CursorColorPagePresenter.cpp new file mode 100644 index 0000000..ca1df8b --- /dev/null +++ b/src/presenter/CursorColorPagePresenter.cpp @@ -0,0 +1,23 @@ +#include "CursorColorPagePresenter.hpp" + +#include "AppContext.hpp" + +CursorColorPagePresenter::CursorColorPagePresenter() +{ + setTitle("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL"); + groups_.emplace_back(""); + auto &items = groups_.back().items_; + for (auto color : colors_) { + items.push_back(std::make_unique( + model_.getColorText(color), + std::string{}, + [this, color](auto item) { + this->model_.cursorColor_ = color; + Singleton::instance().pop(); + }, + ListItem::WidgetType::radio, + std::function{}, + std::function{}, + color == model_.cursorColor_.value())); + } +} \ No newline at end of file diff --git a/src/presenter/CursorColorPagePresenter.hpp b/src/presenter/CursorColorPagePresenter.hpp new file mode 100644 index 0000000..b07594a --- /dev/null +++ b/src/presenter/CursorColorPagePresenter.hpp @@ -0,0 +1,25 @@ +#ifndef CURSOR_COLOR_PAGE_PRESENTER_HPP +#define CURSOR_COLOR_PAGE_PRESENTER_HPP + +#include "CursorColorModel.hpp" +#include "ListPresenter.hpp" + +#include + +class CursorColorPagePresenter : public ListPresenter +{ + public: + CursorColorPagePresenter(); + + private: + CursorColorModel model_; + std::vector colors_ = { + Color::RED, + Color::ORANGE, + Color::YELLOW, + Color::GREEN, + Color::BLUE, + Color::GRAY}; +}; + +#endif \ No newline at end of file diff --git a/src/presenter/UniversalSwitchSettingsPagePresenter.cpp b/src/presenter/UniversalSwitchSettingsPagePresenter.cpp index af32d40..f2ea22b 100644 --- a/src/presenter/UniversalSwitchSettingsPagePresenter.cpp +++ b/src/presenter/UniversalSwitchSettingsPagePresenter.cpp @@ -4,6 +4,7 @@ #include "AutoMoveIntervalPresenter.hpp" #include "AutoScanIntervalPresenter.hpp" #include "AutoTapPresenter.hpp" +#include "CursorColorPagePresenter.hpp" #include "ManageMenuOptionsPagePresenter.hpp" #include "NumberOfAutoScanLoopsPresenter.hpp" #include "PauseOnFirstPresenter.hpp" @@ -271,13 +272,13 @@ void UniversalSwitchSettingsPagePresenter::createFeedbackGroup() items.push_back(std::make_unique( std::string{"IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL"}, - getColorText(model_.cursorColor_.value()), + cursorColorModel_.getColorText(cursorColorModel_.cursorColor_.value()), [this](auto item) { - DEBUG("cursor color widget"); + Singleton::instance().push(std::make_unique()); })); auto item = items.back().get(); - model_.cursorColor_.attach([item, this](auto value) { - item->description_ = getColorText(value); + cursorColorModel_.cursorColor_.attach([item, this](auto value) { + item->description_ = this->cursorColorModel_.getColorText(value); }); items.push_back(std::make_unique( @@ -373,21 +374,3 @@ std::string UniversalSwitchSettingsPagePresenter::getScanMethodText(ScanMethod s return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_UNDEFINED"; } } - -std::string UniversalSwitchSettingsPagePresenter::getColorText(Color color) -{ - if (color == Color::RED) - return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_RED"; - if (color == Color::ORANGE) - return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_ORANGE"; - if (color == Color::YELLOW) - return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_YELLOW"; - if (color == Color::GREEN) - return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_GREEN"; - if (color == Color::BLUE) - return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_BLUE"; - if (color == Color::GRAY) - return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_FEEDBACK_CURSOR_CL_GRAY"; - - return "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_UNDEFINED"; -} diff --git a/src/presenter/UniversalSwitchSettingsPagePresenter.hpp b/src/presenter/UniversalSwitchSettingsPagePresenter.hpp index 5f83fe1..6489159 100644 --- a/src/presenter/UniversalSwitchSettingsPagePresenter.hpp +++ b/src/presenter/UniversalSwitchSettingsPagePresenter.hpp @@ -4,6 +4,7 @@ #include "AutoMoveIntervalModel.hpp" #include "AutoScanModel.hpp" #include "AutoTapModel.hpp" +#include "CursorColorModel.hpp" #include "ListPresenter.hpp" #include "NumberOfAutoScanLoopsModel.hpp" #include "PauseOnFirstModel.hpp" @@ -27,7 +28,6 @@ class UniversalSwitchSettingsPagePresenter : public ListPresenter void createFeedbackGroup(); static std::string getScanDirectionText(ScanDirection scanDirection); static std::string getScanMethodText(ScanMethod scanMethod); - static std::string getColorText(Color color); UniversalSwitchSettingsPageModel model_; AutoScanModel autoScanModel_; @@ -40,6 +40,7 @@ class UniversalSwitchSettingsPagePresenter : public ListPresenter AutoMoveIntervalModel autoMoveIntervalModel_; SoundModel soundModel_; VoiceModel voiceModel_; + CursorColorModel cursorColorModel_; std::unique_ptr switchesPage_; }; diff --git a/src/utils/Geometry.cpp b/src/utils/Geometry.cpp index 2614597..4f1aea1 100644 --- a/src/utils/Geometry.cpp +++ b/src/utils/Geometry.cpp @@ -101,7 +101,7 @@ int Color::toRGBAInt() const int Color::toABGRInt() const { - return (a << 24) | (b << 16) | (r << 8) | g; + return (a << 24) | (b << 16) | (g << 8) | r; } Color Color::invert() const