From 490845caaa8cdf8bc72e4001065f57c91db5125b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jo=C5=84ski?= Date: Tue, 14 Sep 2021 11:10:56 +0200 Subject: [PATCH] [BH-593] Set alarm from menu Set alarm from menu --- .../ApplicationBellAlarm.cpp | 5 ++++- .../presenter/BellAlarmWindowPresenter.cpp | 19 ++++++++++++++++++- .../presenter/BellAlarmWindowPresenter.hpp | 10 ++++++++++ .../windows/BellAlarmWindow.cpp | 11 +++++++++++ .../windows/BellAlarmWindow.hpp | 3 +++ .../presenters/HomeScreenPresenter.cpp | 1 + 6 files changed, 47 insertions(+), 2 deletions(-) diff --git a/products/BellHybrid/apps/application-bell-alarm/ApplicationBellAlarm.cpp b/products/BellHybrid/apps/application-bell-alarm/ApplicationBellAlarm.cpp index 47761a4acd2a6012a288a8f15075070d9b003ba7..0aa138afc287000979f16f539705fb4d136117ee 100644 --- a/products/BellHybrid/apps/application-bell-alarm/ApplicationBellAlarm.cpp +++ b/products/BellHybrid/apps/application-bell-alarm/ApplicationBellAlarm.cpp @@ -5,6 +5,8 @@ #include "presenter/BellAlarmWindowPresenter.hpp" #include "windows/BellAlarmWindow.hpp" +#include + namespace app { ApplicationBellAlarm::ApplicationBellAlarm(std::string name, @@ -30,7 +32,8 @@ namespace app void ApplicationBellAlarm::createUserInterface() { windowsFactory.attach(gui::name::window::main_window, [](ApplicationCommon *app, const std::string &name) { - auto presenter = std::make_unique(); + auto alarmModel = std::make_unique(app); + auto presenter = std::make_unique(std::move(alarmModel)); return std::make_unique(app, std::move(presenter)); }); diff --git a/products/BellHybrid/apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.cpp b/products/BellHybrid/apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.cpp index 7b9a3e8ea185149ac5223ebb6e993165c214e318..fb84723d040a4bc67e92e50cd1ce9c2e515b7216 100644 --- a/products/BellHybrid/apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.cpp +++ b/products/BellHybrid/apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.cpp @@ -5,8 +5,25 @@ namespace app::bell_alarm { + BellAlarmWindowPresenter::BellAlarmWindowPresenter(std::unique_ptr &&alarmModel) + : alarmModel{std::move(alarmModel)} + {} + auto BellAlarmWindowPresenter::saveData() -> void { - // TODO + auto view = getView(); + auto time = view->getAlarmTime(); + alarmModel->setAlarmTime(time); + } + + auto BellAlarmWindowPresenter::createData() -> void + { + auto updateAlarmTimeCallback = [&]() { + auto time = alarmModel->getAlarmTime(); + auto view = getView(); + view->setAlarmTime(time); + }; + + alarmModel->update(updateAlarmTimeCallback); } } // namespace app::bell_alarm diff --git a/products/BellHybrid/apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.hpp b/products/BellHybrid/apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.hpp index 3c1dff1bb296a921f5d6ad93fa55c6d739244d7f..1d44af78c90e10dc9f3849eb644c81a28488090c 100644 --- a/products/BellHybrid/apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.hpp +++ b/products/BellHybrid/apps/application-bell-alarm/presenter/BellAlarmWindowPresenter.hpp @@ -5,6 +5,8 @@ #pragma once #include +#include +#include