~aleteoryx/muditaos

68f315b385c5f4f81f6717b6f654e8a9af200de9 — Mateusz Grzegorzek 4 years ago b086426
[BH-956] Fix PrewakeUp settings window bug

Fix bug which causes that
settings are saved even if the window
was exited with the back button.
M products/BellHybrid/apps/application-bell-bedtime/models/BedtimeListItemProvider.cpp => products/BellHybrid/apps/application-bell-bedtime/models/BedtimeListItemProvider.cpp +1 -0
@@ 29,6 29,7 @@ namespace app::bell_bedtime
            if (not onOff->isActive()) {
                this->onExit(false);
            }
            return true;
        };
        internalData.emplace_back(onOff);
        internalData.emplace_back(new TimeListItem(model.get()->getBedtimeTime(),

M products/BellHybrid/apps/application-bell-settings/models/alarm_settings/PrewakeUpListItemProvider.cpp => products/BellHybrid/apps/application-bell-settings/models/alarm_settings/PrewakeUpListItemProvider.cpp +12 -4
@@ 34,12 34,16 @@ namespace app::bell_settings
            chimeDurationRange,
            utils::translate("app_bell_settings_alarm_settings_prewake_up_chime_top_description"),
            utils::translate("app_bell_settings_alarm_settings_prewake_up_chime_bottom_description"));
        chimeDuration->onExit = [chimeDuration, this] {

        chimeDuration->onProceed = [chimeDuration, this]() {
            if (chimeDuration->isOff()) {
                constexpr auto lightDurationListIndex = 3U;
                list->rebuildList(gui::listview::RebuildType::OnOffset, lightDurationListIndex);
                return true;
            }
            return false;
        };

        internalData.emplace_back(chimeDuration);

        auto chimeTone = new UTF8ListItem(model.getChimeTone(),


@@ 97,11 101,15 @@ namespace app::bell_settings
            lightDurationRange,
            utils::translate("app_bell_settings_alarm_settings_prewake_up_light_top_description"),
            utils::translate("app_bell_settings_alarm_settings_prewake_up_light_bottom_description"));
        lightDuration->onExit = [lightDuration, this] {
            if (lightDuration->isOff()) {
                this->onExit();

        lightDuration->onReturn = [chimeDuration, this]() {
            if (chimeDuration->isOff()) {
                list->rebuildList(gui::listview::RebuildType::OnOffset, 0);
                return true;
            }
            return false;
        };

        internalData.emplace_back(lightDuration);

        for (auto item : internalData) {

M products/BellHybrid/apps/common/include/common/widgets/BellSideListItemWithCallbacks.hpp => products/BellHybrid/apps/common/include/common/widgets/BellSideListItemWithCallbacks.hpp +3 -1
@@ 19,10 19,12 @@ namespace gui
        std::function<void()> onEnter;
        std::function<void()> onExit;

        std::function<void()> onProceed;
        std::function<bool()> onProceed;
        std::function<bool()> onReturn;

      protected:
        void OnFocusChangedCallback();
        bool OnInputCallback(const InputEvent &inputEvent);
    };

} // namespace gui

M products/BellHybrid/apps/common/src/BellSideListItemWithCallbacks.cpp => products/BellHybrid/apps/common/src/BellSideListItemWithCallbacks.cpp +16 -8
@@ 21,14 21,7 @@ namespace gui
            return true;
        };

        inputCallback = [&](Item &, const InputEvent &inputEvent) -> bool {
            if (inputEvent.isShortRelease(KeyCode::KEY_ENTER)) {
                if (onProceed) {
                    onProceed();
                }
            }
            return body->onInput(inputEvent);
        };
        inputCallback = [&](Item &, const InputEvent &inputEvent) -> bool { return OnInputCallback(inputEvent); };
    }

    void BellSideListItemWithCallbacks::OnFocusChangedCallback()


@@ 46,4 39,19 @@ namespace gui
            }
        }
    }

    bool BellSideListItemWithCallbacks::OnInputCallback(const InputEvent &inputEvent)
    {
        if (inputEvent.isShortRelease(KeyCode::KEY_ENTER)) {
            if (onProceed && onProceed()) {
                return true;
            }
        }
        else if (inputEvent.isShortRelease(KeyCode::KEY_RF)) {
            if (onReturn && onReturn()) {
                return true;
            }
        }
        return body->onInput(inputEvent);
    }
} // namespace gui

M products/BellHybrid/apps/common/src/widgets/ListItems.cpp => products/BellHybrid/apps/common/src/widgets/ListItems.cpp +1 -1
@@ 88,7 88,7 @@ namespace gui
        setupBottomDescription(bottomDescription);

        inputCallback = [&, range](Item &item, const InputEvent &event) {
            const auto result = body->onInput(event);
            const auto result = OnInputCallback(event);
            bottomText->setVisible(spinner->getCurrentValue().getValue().has_value());
            setArrowsVisibility(range);
            return result;