From c38aa53b7da04a038728d25b4ca00821a7157fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jo=C5=84ski?= Date: Tue, 18 Jan 2022 13:21:00 +0100 Subject: [PATCH] [BH-1381] Fix alarm settings regression Fix alarm settings regression --- .../alarm_settings/AlarmSettingsPresenter.cpp | 9 +++++++- .../alarm_settings/AlarmSettingsPresenter.hpp | 11 +++++---- .../BellSettingsAlarmSettingsWindow.cpp | 23 ++++++++----------- .../BellSettingsAlarmSettingsWindow.hpp | 2 -- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.cpp b/products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.cpp index ebb5113b0b414f7cc5df2d9d31ad879fab4ee0f7..cbf100aa6b285a22e849a650308f34c5e5d6a4af 100644 --- a/products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.cpp +++ b/products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.cpp @@ -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 diff --git a/products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.hpp b/products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.hpp index d64bcc61ad922c9e6d75d34a0311f85faf97d1cb..0f3edcd251cfd2a1106dc8fb2cfbe054d76d353b 100644 --- a/products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.hpp +++ b/products/BellHybrid/apps/application-bell-settings/presenter/alarm_settings/AlarmSettingsPresenter.hpp @@ -34,10 +34,10 @@ namespace app::bell_settings public: virtual ~Presenter() noexcept = default; virtual auto getPagesProvider() const -> std::shared_ptr = 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 soundsRepository); auto getPagesProvider() const -> std::shared_ptr 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 provider; std::unique_ptr model; diff --git a/products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.cpp b/products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.cpp index 8524180e814081098dc55be672ec850d6f6164d0..9b95815cde73cebad11f03e0e8718a0655beb9da 100644 --- a/products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.cpp +++ b/products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.cpp @@ -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 */ diff --git a/products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.hpp b/products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.hpp index 9c5a4363c598425b5603ddc6a11ed2d2477c0fa8..7039d585a37a785f473307fea6fa9774049126c6 100644 --- a/products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.hpp +++ b/products/BellHybrid/apps/application-bell-settings/windows/alarm_settings/BellSettingsAlarmSettingsWindow.hpp @@ -21,8 +21,6 @@ namespace gui app::ApplicationCommon *app, std::unique_ptr presenter); - ~BellSettingsAlarmSettingsWindow(); - void buildInterface() override; void onClose(CloseReason reason) override; bool onInput(const InputEvent &inputEvent) override;