From eb0af22ecf66957b9341521990c49a6d1d5d70e3 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Tue, 11 Oct 2022 21:36:31 +0200 Subject: Watch face settings : disable watch faces that are not available (external resources are not installed). --- src/displayapp/screens/CheckboxList.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/displayapp/screens/CheckboxList.cpp') diff --git a/src/displayapp/screens/CheckboxList.cpp b/src/displayapp/screens/CheckboxList.cpp index d97726dd..5889c69a 100644 --- a/src/displayapp/screens/CheckboxList.cpp +++ b/src/displayapp/screens/CheckboxList.cpp @@ -18,7 +18,7 @@ CheckboxList::CheckboxList(const uint8_t screenID, const char* optionsSymbol, uint32_t originalValue, std::function OnValueChanged, - std::array options) + std::array options) : Screen(app), screenID {screenID}, OnValueChanged {std::move(OnValueChanged)}, options {options}, value {originalValue} { // Set the background to Black lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); @@ -72,9 +72,12 @@ CheckboxList::CheckboxList(const uint8_t screenID, lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); for (unsigned int i = 0; i < options.size(); i++) { - if (strcmp(options[i], "")) { + if (strcmp(options[i].name, "")) { cbOption[i] = lv_checkbox_create(container1, nullptr); - lv_checkbox_set_text(cbOption[i], options[i]); + lv_checkbox_set_text(cbOption[i], options[i].name); + if (!options[i].enabled) { + lv_checkbox_set_disabled(cbOption[i]); + } cbOption[i]->user_data = this; lv_obj_set_event_cb(cbOption[i], event_handler); SetRadioButtonStyle(cbOption[i]); @@ -94,13 +97,16 @@ CheckboxList::~CheckboxList() { void CheckboxList::UpdateSelected(lv_obj_t* object, lv_event_t event) { if (event == LV_EVENT_VALUE_CHANGED) { for (unsigned int i = 0; i < options.size(); i++) { - if (strcmp(options[i], "")) { + if (strcmp(options[i].name, "")) { if (object == cbOption[i]) { lv_checkbox_set_checked(cbOption[i], true); value = MaxItems * screenID + i; } else { lv_checkbox_set_checked(cbOption[i], false); } + if (!options[i].enabled) { + lv_checkbox_set_disabled(cbOption[i]); + } } } } -- cgit v1.2.3-70-g09d2