From 4b9722a64639f73da8af2d7f327f5f0de70bc3bf Mon Sep 17 00:00:00 2001 From: Lukasz Wlazly Date: Tue, 19 Mar 2019 10:54:55 +0100 Subject: [PATCH] Create "Single interaction interval" item with new genlist API Change-Id: I7e871889bf59cdc22ceebe17d8e302270bfa2210 --- src/UniversalSwitchSettingsPage.cpp | 94 ++++++++++++++++++------------------- src/UniversalSwitchSettingsPage.hpp | 4 +- 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/src/UniversalSwitchSettingsPage.cpp b/src/UniversalSwitchSettingsPage.cpp index 8820870..98f3289 100644 --- a/src/UniversalSwitchSettingsPage.cpp +++ b/src/UniversalSwitchSettingsPage.cpp @@ -301,9 +301,40 @@ void UniversalSwitchSettingsPage::createAdditionalSettingsGroup() str = getValueUnitText(NULL, &context_->us_configuration.sgl_iaction_int_value, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"), !context_->us_configuration.sgl_iaction_int_state, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF")); - universal_switch_sgl_iaction_int = addMenuItem(_("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_SGL_IACTION_INT"), - str, sglInactionIntervalCb, true, context_->us_configuration.sgl_iaction_int_state, sglInactionIntervalCheckboxCb); - universal_switch_sgl_iaction_int->userdata = this; + + singleInteractionInterval_ = genlist_->appendItem({"type1", "IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_SGL_IACTION_INT", str, + [this](auto item) + { + setValuePage_ = std::make_unique(context_, ValueEditorType::NUMERIC_SWITCH, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_SGL_IACTION_INT")); + setValuePage_->setSwitch(context_->us_configuration.sgl_iaction_int_state); + setValuePage_->addValueChangedCb([this](auto val) { + this->sglInactionIntervalValueChangedCb(val); + }); + setValuePage_->addSwitchChangedCb([this](auto state) { + this->sglInactionIntervalSwitchChangedCb(state); + }); + setValuePage_->setDescription(_("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SET_VALUE_DESC_SGL_IACTION_INT")); + setValuePage_->setRange(RANGE_MIN_SGL_IACTION_INT, RANGE_MAX_SGL_IACTION_INT, STEP_SGL_IACTION_INT); + setValuePage_->setValue(context_->us_configuration.sgl_iaction_int_value, "seconds"); + }, + [this](auto item) + { + context_->us_configuration.sgl_iaction_int_state = item->getState(); + auto str = getValueUnitText(NULL, &context_->us_configuration.sgl_iaction_int_value, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"), + !context_->us_configuration.sgl_iaction_int_state, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF")); + item->setDescription(str); + item->update(); + vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SGL_IACTION_INT_STATE, item->getState()); + }, GenlistItem::WidgetType::toggle + }); + + if (context_->us_configuration.sgl_iaction_int_state) { + singleInteractionInterval_->setState(true); + auto str = getValueUnitText(NULL, &context_->us_configuration.sgl_iaction_int_value, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"), + !context_->us_configuration.sgl_iaction_int_state, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF")); + singleInteractionInterval_->setDescription(str); + singleInteractionInterval_->update(); + } str = getValueUnitText(NULL, &context_->us_configuration.auto_tap_value, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"), !context_->us_configuration.auto_tap_state, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF")); @@ -917,60 +948,25 @@ void UniversalSwitchSettingsPage::autoTapCheckboxCb(void *data, Evas_Object *obj updateVconfValue(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_AUTO_TAP_STATE, (bool *)&list_item->chk_status, NULL, NULL); } -void UniversalSwitchSettingsPage::sglInactionIntervalCb(void *data, Evas_Object *obj, void *event_info) -{ - auto self = static_cast(data); - elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); - - self->setValuePage_ = std::make_unique(self->context_, ValueEditorType::NUMERIC_SWITCH, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_GROUP_ADD_SETTINGS_SGL_IACTION_INT")); - self->setValuePage_->setSwitch(self->context_->us_configuration.sgl_iaction_int_state); - self->setValuePage_->addValueChangedCb([self](auto val) { - self->sglInactionIntervalValueChangedCb(val); - }); - self->setValuePage_->addSwitchChangedCb([self](auto state) { - self->sglInactionIntervalSwitchChangedCb(state); - }); - self->setValuePage_->setDescription(_("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SET_VALUE_DESC_SGL_IACTION_INT")); - self->setValuePage_->setRange(RANGE_MIN_SGL_IACTION_INT, RANGE_MAX_SGL_IACTION_INT, STEP_SGL_IACTION_INT); - self->setValuePage_->setValue(self->context_->us_configuration.sgl_iaction_int_value, "seconds"); -} - void UniversalSwitchSettingsPage::sglInactionIntervalSwitchChangedCb(bool state) { context_->us_configuration.sgl_iaction_int_state = state; - updateVconfValue(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SGL_IACTION_INT_STATE, &state, NULL, NULL); - - universal_switch_sgl_iaction_int->chk_status = state; - elm_check_state_set(universal_switch_sgl_iaction_int->eo_check, state); - universal_switch_sgl_iaction_int->sub_desc = getValueUnitText(NULL, &context_->us_configuration.sgl_iaction_int_value, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"), - !context_->us_configuration.sgl_iaction_int_state, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF")); - elm_genlist_item_update(universal_switch_sgl_iaction_int->item); + vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SGL_IACTION_INT_STATE, state); + singleInteractionInterval_->setState(state); + auto str = getValueUnitText(NULL, &context_->us_configuration.sgl_iaction_int_value, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"), + !context_->us_configuration.sgl_iaction_int_state, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF")); + singleInteractionInterval_->setDescription(str); + singleInteractionInterval_->update(); } void UniversalSwitchSettingsPage::sglInactionIntervalValueChangedCb(double value) { context_->us_configuration.sgl_iaction_int_value = value; - updateVconfValue(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SGL_IACTION_INT_VALUE, NULL, NULL, &value); - - universal_switch_sgl_iaction_int->sub_desc = getValueUnitText(NULL, &context_->us_configuration.sgl_iaction_int_value, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"), - !context_->us_configuration.sgl_iaction_int_state, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF")); - elm_genlist_item_update(universal_switch_sgl_iaction_int->item); -} - -void UniversalSwitchSettingsPage::sglInactionIntervalCheckboxCb(void *data, Evas_Object *obj, void *event_info) -{ - retm_if(data == NULL, "Data parameter is NULL"); - auto list_item = static_cast(data); - auto self = static_cast(list_item->userdata); - - list_item->chk_status = elm_check_state_get(obj); - self->context_->us_configuration.sgl_iaction_int_state = list_item->chk_status; - - self->universal_switch_sgl_iaction_int->sub_desc = getValueUnitText(NULL, &self->context_->us_configuration.sgl_iaction_int_value, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"), - !self->context_->us_configuration.sgl_iaction_int_state, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF")); - elm_genlist_item_update(self->universal_switch_sgl_iaction_int->item); - - updateVconfValue(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SGL_IACTION_INT_STATE, (bool *)&list_item->chk_status, NULL, NULL); + vconf_set_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_UNIVERSAL_SWITCH_SETTINGS_SGL_IACTION_INT_VALUE, value); + auto str = getValueUnitText(NULL, &context_->us_configuration.sgl_iaction_int_value, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_SECONDS"), + !context_->us_configuration.sgl_iaction_int_state, _("IDS_ACCS_UNIVERSAL_SWITCH_SETTINGS_OFF")); + singleInteractionInterval_->setDescription(str); + singleInteractionInterval_->update(); } void UniversalSwitchSettingsPage::tapDurationSwitchChangedCb(bool state) diff --git a/src/UniversalSwitchSettingsPage.hpp b/src/UniversalSwitchSettingsPage.hpp index 7b1301b..78d0e5c 100644 --- a/src/UniversalSwitchSettingsPage.hpp +++ b/src/UniversalSwitchSettingsPage.hpp @@ -86,10 +86,8 @@ private: void autoTapSwitchChangedCb(bool state); void autoTapValueChangedCb(double value); static void autoTapCheckboxCb(void *data, Evas_Object *obj, void *event_info); - static void sglInactionIntervalCb(void *data, Evas_Object *obj, void *event_info); void sglInactionIntervalSwitchChangedCb(bool state); void sglInactionIntervalValueChangedCb(double value); - static void sglInactionIntervalCheckboxCb(void *data, Evas_Object *obj, void *event_info); void tapDurationSwitchChangedCb(bool state); void tapDurationValueChangedCb(double value); void pauseOnFirstSwitchChangedCb(bool state); @@ -127,7 +125,7 @@ private: GenGroupItemData *universal_switch_feedback_voice_speech_volume = nullptr; GenGroupItemData *universal_switch_auto_move_int = nullptr; GenGroupItemData *universal_switch_auto_tap = nullptr; - GenGroupItemData *universal_switch_sgl_iaction_int = nullptr; + GenlistItem *singleInteractionInterval_ = nullptr; GenlistItem *tapDuration_ = nullptr; GenlistItem *pauseOnFirst_ = nullptr; GenGroupItemData *universal_switch_scan_speed = nullptr; -- 2.7.4