--- /dev/null
+#include "CursorColorModel.hpp"
+
+#include "UniversalSwitchConstants.hpp"
+
+CursorColorModel::CursorColorModel()
+{
+ vconfHandle_ = Singleton<VConfInterface>::instance().registerAndGet<int>(
+ 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<VConfInterface>::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
--- /dev/null
+#ifndef CURSOR_COLOR_MODEL_HPP
+#define CURSOR_COLOR_MODEL_HPP
+
+#include "Geometry.hpp"
+#include "ObservableProperty.hpp"
+#include "VConf.hpp"
+
+class CursorColorModel
+{
+ public:
+ CursorColorModel();
+ ObservableProperty<Color> cursorColor_;
+ std::string getColorText(Color color);
+
+ private:
+ VConfInterface::CallbackHandle vconfHandle_;
+};
+
+#endif
\ No newline at end of file
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<VConfInterface>::instance().registerAndGet<int>(
- 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<VConfInterface>::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<DBus::ValueOrError<std::vector<std::tuple<std::string, std::string, std::string, int32_t>>>()>("getAllSwitchConfigurationItems").call();
ObservableProperty<ScanDirection> scanDirection_;
ObservableProperty<bool> autoTapKeyboardState_;
- ObservableProperty<Color> cursorColor_;
-
private:
template <typename T>
void synchronizePropertyWithVConf(ObservableProperty<T> &property, const std::string &vconfKey, T defaultValue)
--- /dev/null
+#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<ListItem>(
+ model_.getColorText(color),
+ std::string{},
+ [this, color](auto item) {
+ this->model_.cursorColor_ = color;
+ Singleton<AppContext>::instance().pop();
+ },
+ ListItem::WidgetType::radio,
+ std::function<void(ListItem * item)>{},
+ std::function<void(ListItem * item)>{},
+ color == model_.cursorColor_.value()));
+ }
+}
\ No newline at end of file
--- /dev/null
+#ifndef CURSOR_COLOR_PAGE_PRESENTER_HPP
+#define CURSOR_COLOR_PAGE_PRESENTER_HPP
+
+#include "CursorColorModel.hpp"
+#include "ListPresenter.hpp"
+
+#include <vector>
+
+class CursorColorPagePresenter : public ListPresenter
+{
+ public:
+ CursorColorPagePresenter();
+
+ private:
+ CursorColorModel model_;
+ std::vector<Color> colors_ = {
+ Color::RED,
+ Color::ORANGE,
+ Color::YELLOW,
+ Color::GREEN,
+ Color::BLUE,
+ Color::GRAY};
+};
+
+#endif
\ No newline at end of file
#include "AutoMoveIntervalPresenter.hpp"
#include "AutoScanIntervalPresenter.hpp"
#include "AutoTapPresenter.hpp"
+#include "CursorColorPagePresenter.hpp"
#include "ManageMenuOptionsPagePresenter.hpp"
#include "NumberOfAutoScanLoopsPresenter.hpp"
#include "PauseOnFirstPresenter.hpp"
items.push_back(std::make_unique<ListItem>(
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<AppContext>::instance().push(std::make_unique<CursorColorPagePresenter>());
}));
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<ListItem>(
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";
-}
#include "AutoMoveIntervalModel.hpp"
#include "AutoScanModel.hpp"
#include "AutoTapModel.hpp"
+#include "CursorColorModel.hpp"
#include "ListPresenter.hpp"
#include "NumberOfAutoScanLoopsModel.hpp"
#include "PauseOnFirstModel.hpp"
void createFeedbackGroup();
static std::string getScanDirectionText(ScanDirection scanDirection);
static std::string getScanMethodText(ScanMethod scanMethod);
- static std::string getColorText(Color color);
UniversalSwitchSettingsPageModel model_;
AutoScanModel autoScanModel_;
AutoMoveIntervalModel autoMoveIntervalModel_;
SoundModel soundModel_;
VoiceModel voiceModel_;
+ CursorColorModel cursorColorModel_;
std::unique_ptr<SwitchesPage> switchesPage_;
};
int Color::toABGRInt() const
{
- return (a << 24) | (b << 16) | (r << 8) | g;
+ return (a << 24) | (b << 16) | (g << 8) | r;
}
Color Color::invert() const