~aleteoryx/muditaos

c38aa53b7da04a038728d25b4ca00821a7157fe2 — Paweł Joński 3 years ago f6b7892
[BH-1381] Fix alarm settings regression

Fix alarm settings regression
M products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.cpp => products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.cpp +8 -1
@@ 59,8 59,15 @@ namespace app::bell_settings
    {
        this->audioModel.stopPlayedByThis({});
    }
    void AlarmSettingsPresenter::exitWithoutSave()
    void AlarmSettingsPresenter::exitWithSave()
    {
        saveData();
        eraseProviderData();
    }

    void AlarmSettingsPresenter::exitWithRollback()
    {
        model->getAlarmVolume().restoreDefault();
        eraseProviderData();
    }
} // namespace app::bell_settings

M products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.hpp => products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.hpp +6 -5
@@ 34,10 34,10 @@ namespace app::bell_settings
          public:
            virtual ~Presenter() noexcept                                                   = default;
            virtual auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> = 0;
            virtual auto saveData() -> void                                                 = 0;
            virtual auto loadData() -> void                                                 = 0;
            virtual auto eraseProviderData() -> void                                        = 0;
            virtual void exitWithoutSave()                                                  = 0;
            virtual auto exitWithSave() -> void                                             = 0;
            virtual auto exitWithRollback() -> void                                         = 0;
        };
    };



@@ 50,13 50,14 @@ namespace app::bell_settings
                               std::unique_ptr<AbstractSoundsRepository> soundsRepository);

        auto getPagesProvider() const -> std::shared_ptr<gui::ListItemProvider> override;
        auto saveData() -> void override;
        auto loadData() -> void override;
        auto eraseProviderData() -> void override;
        void exitWithoutSave() override;
        auto exitWithSave() -> void override;
        auto exitWithRollback() -> void override;

      private:
        void stopSound();
        auto stopSound() -> void;
        auto saveData() -> void;

        std::shared_ptr<AlarmSettingsListItemProvider> provider;
        std::unique_ptr<AbstractAlarmSettingsModel> model;

M products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.cpp +9 -14
@@ 26,6 26,7 @@ namespace gui
    {
        erase();
        buildInterface();
        isSaveNeeded = false;
    }

    void BellSettingsAlarmSettingsWindow::buildInterface()


@@ 52,19 53,16 @@ namespace gui
            return true;
        }
        if (inputEvent.isShortRelease(KeyCode::KEY_ENTER)) {
            isSaveNeeded = true;
            exit();
            return true;
        }
        if (inputEvent.isShortRelease(KeyCode::KEY_RF)) {
            presenter->exitWithoutSave();
        }

        return AppWindow::onInput(inputEvent);
    }

    void BellSettingsAlarmSettingsWindow::exit()
    {
        isSaveNeeded = true;
        application->switchWindow(
            window::bell_finished::defaultName,
            BellFinishedWindowData::Factory::create("circle_success_big", BellSettingsAlarmSettingsMenuWindow::name));


@@ 73,16 71,13 @@ namespace gui
    void BellSettingsAlarmSettingsWindow::onClose(CloseReason reason)
    {
        if (reason != CloseReason::Popup) {
            presenter->eraseProviderData();
        }
    }
    BellSettingsAlarmSettingsWindow::~BellSettingsAlarmSettingsWindow()
    {
        if (isSaveNeeded) {
            presenter->saveData();
        }
        else {
            presenter->exitWithoutSave();
            if (isSaveNeeded) {
                presenter->exitWithSave();
            }
            else {
                presenter->exitWithRollback();
            }
        }
    }

} /* namespace gui */

M products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.hpp => products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.hpp +0 -2
@@ 21,8 21,6 @@ namespace gui
            app::ApplicationCommon *app,
            std::unique_ptr<app::bell_settings::AlarmSettingsWindowContract::Presenter> presenter);

        ~BellSettingsAlarmSettingsWindow();

        void buildInterface() override;
        void onClose(CloseReason reason) override;
        bool onInput(const InputEvent &inputEvent) override;