From 85a6dba50db83e014b9bdc1c89292e24d0c4cb54 Mon Sep 17 00:00:00 2001 From: Lefucjusz Date: Thu, 25 Jul 2024 22:35:29 +0200 Subject: [PATCH] [BH-2054] Fix build with CONFIG_ENABLE_TEMP set to ON * Fix of the issue that project build would fail if trying to run it with enabled temperature sensor. The sensor itself is not functional due to hardware issue, but if such option is present in the codebase, it should be kept working. * Cleanups. --- .../service-evtmgr/EventManagerCommon.hpp | 13 ++--- .../presenters/StateController.cpp | 2 - .../models/LayoutModel.cpp | 5 +- .../models/TemperatureUnitModel.cpp | 3 +- .../presenter/LayoutWindowPresenter.cpp | 43 +++++++++-------- .../layouts/BaseHomeScreenLayoutProvider.hpp | 8 ++-- .../layouts/HomeScreenLayoutClassic.hpp | 48 +++++++++---------- .../HomeScreenLayoutClassicWithAmPm.hpp | 6 +-- .../HomeScreenLayoutClassicWithBattery.hpp | 6 +-- .../HomeScreenLayoutClassicWithDate.hpp | 9 ++-- .../HomeScreenLayoutClassicWithQuotes.hpp | 2 +- .../HomeScreenLayoutClassicWithQuotesAmPm.hpp | 2 +- .../HomeScreenLayoutClassicWithTemp.hpp | 13 +++-- .../common/layouts/HomeScreenLayoutNames.hpp | 30 ++++++------ .../layouts/HomeScreenLayoutVertical.hpp | 13 +++-- .../HomeScreenLayoutVerticalSimple.hpp | 6 +-- .../HomeScreenLayoutVerticalWithAmPm.hpp | 10 ++-- .../HomeScreenLayoutVerticalWithDate.hpp | 11 ++--- .../common/layouts/HomeScreenLayouts.hpp | 4 +- .../layouts/ShortcutsLayoutProvider.hpp | 4 +- .../common/layouts/ShortcutsLayouts.hpp | 5 +- .../UpdateInstructionLayoutClassic.hpp | 2 +- .../UpdateInstructionLayoutProvider.hpp | 2 +- .../layouts/UpdateInstructionLayouts.hpp | 3 +- .../src/layouts/HomeScreenLayoutClassic.cpp | 8 +--- .../HomeScreenLayoutClassicWithAmPm.cpp | 4 +- .../HomeScreenLayoutClassicWithBattery.cpp | 4 +- .../HomeScreenLayoutClassicWithDate.cpp | 2 +- .../HomeScreenLayoutClassicWithQuotesAmPm.cpp | 3 +- .../HomeScreenLayoutClassicWithTemp.cpp | 12 +++-- .../src/layouts/HomeScreenLayoutVertical.cpp | 7 ++- .../HomeScreenLayoutVerticalSimple.cpp | 4 +- .../HomeScreenLayoutVerticalWithAmPm.cpp | 6 +-- .../HomeScreenLayoutVerticalWithDate.cpp | 7 +-- .../common/src/layouts/HomeScreenLayouts.cpp | 4 +- .../src/layouts/ShortcutsLayoutClassic.cpp | 16 +++---- .../UpdateInstructionLayoutClassic.cpp | 40 ++++++++-------- .../services/evtmgr/EventManager.cpp | 3 +- 38 files changed, 179 insertions(+), 191 deletions(-) diff --git a/module-services/service-evtmgr/service-evtmgr/EventManagerCommon.hpp b/module-services/service-evtmgr/service-evtmgr/EventManagerCommon.hpp index 7d10199502cb5484408f8bb5b0cc5130a7bd5dbd..e54670b079aedab8015f2bdd9ba661e31415c032 100644 --- a/module-services/service-evtmgr/service-evtmgr/EventManagerCommon.hpp +++ b/module-services/service-evtmgr/service-evtmgr/EventManagerCommon.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -36,7 +36,7 @@ class EventManagerCommon : public sys::Service sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override; // Invoked during initialization - sys::ReturnCodes InitHandler(); + sys::ReturnCodes InitHandler() override; sys::ReturnCodes DeinitHandler() override; @@ -61,11 +61,12 @@ class EventManagerCommon : public sys::Service LogDumpFunction logDumpFunction; protected: - std::function onMinuteTick; virtual void handleKeyEvent(sys::Message *msg); virtual void initProductEvents(); virtual auto createEventWorker() -> std::unique_ptr = 0; + std::function onMinuteTick; + std::shared_ptr settings; std::unique_ptr EventWorker; @@ -73,13 +74,13 @@ class EventManagerCommon : public sys::Service // press settings. std::string targetApplication; // alarm timestamp in seconds from midnight - uint32_t alarmTimestamp; + std::uint32_t alarmTimestamp; // ID of alarm waiting to trigger - uint32_t alarmID; + std::uint32_t alarmID; const EventManagerParams eventManagerParams; /// @return: < 0 - error occured during log flush /// @return: 0 - log flush did not happen - /// @return: 1 - log flush successflul + /// @return: 1 - log flush successful int dumpLogsToFile(); }; diff --git a/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp b/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp index c5f65959c4a8d8828f9f4e5c80e326623258a4b1..669e13591ab05ee553416f7dabf07449f1d3f231 100644 --- a/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp +++ b/products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp @@ -111,8 +111,6 @@ namespace app::home_screen {}; struct DeepDownPress {}; - struct AlarmInput - {}; struct Timer {}; struct TimeUpdate diff --git a/products/BellHybrid/apps/application-bell-settings/models/LayoutModel.cpp b/products/BellHybrid/apps/application-bell-settings/models/LayoutModel.cpp index 977047cd417cac469f7429c25c8fe5aab43dc40c..e04932129a89f3ca5f7fd856e8da1b5a60706315 100644 --- a/products/BellHybrid/apps/application-bell-settings/models/LayoutModel.cpp +++ b/products/BellHybrid/apps/application-bell-settings/models/LayoutModel.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include @@ -8,7 +8,6 @@ namespace app::bell_settings { - LayoutModel::LayoutModel(ApplicationCommon *app) { settings.init(service::ServiceProxy{app->weak_from_this()}); @@ -16,7 +15,7 @@ namespace app::bell_settings std::optional LayoutModel::getValue() const { - if (const auto result = settings.getValue(bell::settings::Layout::layout, settings::SettingsScope::Global); + if (auto result = settings.getValue(bell::settings::Layout::layout, settings::SettingsScope::Global); not result.empty()) { return result; } diff --git a/products/BellHybrid/apps/application-bell-settings/models/TemperatureUnitModel.cpp b/products/BellHybrid/apps/application-bell-settings/models/TemperatureUnitModel.cpp index 3381b8caf4605d072d0ed4f6a32bc37d192b03ec..a3712a8dc9b27df0a4b6a1c753650dd6b37e2881 100644 --- a/products/BellHybrid/apps/application-bell-settings/models/TemperatureUnitModel.cpp +++ b/products/BellHybrid/apps/application-bell-settings/models/TemperatureUnitModel.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "models/TemperatureUnitModel.hpp" @@ -34,5 +34,4 @@ namespace app::bell_settings { settings.setValue(temperatureUnit, utils::temperature::unitToStr(unit), settings::SettingsScope::Global); } - } // namespace app::bell_settings diff --git a/products/BellHybrid/apps/application-bell-settings/presenter/LayoutWindowPresenter.cpp b/products/BellHybrid/apps/application-bell-settings/presenter/LayoutWindowPresenter.cpp index 73a9bc9de09205f7207c4f39466f1a868e0ad4d7..893ec4588f351448ba9e2288b875f43fe4b4a2d1 100644 --- a/products/BellHybrid/apps/application-bell-settings/presenter/LayoutWindowPresenter.cpp +++ b/products/BellHybrid/apps/application-bell-settings/presenter/LayoutWindowPresenter.cpp @@ -2,7 +2,6 @@ // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "LayoutWindowPresenter.hpp" -#include #include #include @@ -10,17 +9,22 @@ #include #include -constexpr auto alarmTime = 0; -constexpr auto clockTime = 0; -constexpr Store::Battery batteryState = { - .levelState = Store::Battery::LevelState::Normal, - .state = Store::Battery::State::Discharging, - .level = 100, -}; -constexpr utils::temperature::Temperature temperature = { - .unit = utils::temperature::Temperature::Unit::Celsius, - .value = 21.0f, -}; +namespace +{ + constexpr auto alarmTime = 0; + constexpr auto clockTime = 0; + + constexpr Store::Battery batteryState = { + .levelState = Store::Battery::LevelState::Normal, + .state = Store::Battery::State::Discharging, + .level = 100, + }; + + constexpr utils::temperature::Temperature temperature = { + .unit = utils::temperature::Temperature::Unit::Celsius, + .value = 21.0f, + }; +} // namespace namespace app::bell_settings { @@ -37,8 +41,9 @@ namespace app::bell_settings std::vector LayoutWindowPresenter::getLayouts() const { std::vector layouts; + layouts.reserve(layoutOptions.size()); - for (auto const &[option, _] : layoutOptions) { + for (const auto &[option, _] : layoutOptions) { layouts.push_back(option->getLayout()); } @@ -47,9 +52,9 @@ namespace app::bell_settings gui::Item *LayoutWindowPresenter::getSelectedLayout() const { - const auto layoutSelected = layoutModel->getValue(); + const auto &layoutSelected = layoutModel->getValue(); - for (auto const &[option, name] : layoutOptions) { + for (const auto &[option, name] : layoutOptions) { if (name == layoutSelected) { return option->getLayout(); } @@ -60,11 +65,11 @@ namespace app::bell_settings void LayoutWindowPresenter::setLayout(gui::Item *selectedLayout) { - for (auto const &[option, name] : layoutOptions) { + for (const auto &[option, name] : layoutOptions) { if (option->getLayout() == selectedLayout) { layoutModel->setValue(name); auto layoutChangeRequest = std::make_shared(name); - app->bus.sendUnicast(layoutChangeRequest, service::name::appmgr); + app->bus.sendUnicast(std::move(layoutChangeRequest), service::name::appmgr); break; } } @@ -72,7 +77,7 @@ namespace app::bell_settings void LayoutWindowPresenter::initLayoutOptions() { - quoteModel->setCallback([=](std::string quote, std::string author) { + quoteModel->setCallback([=](const auto "e, const auto &author) { for (auto &[layout, _] : layoutOptions) { layout->setQuoteText(quote, author); } @@ -92,7 +97,7 @@ namespace app::bell_settings layout->setAlarmTime(alarmTime); layout->setBatteryLevelState(batteryState); layout->setTemperature(temperature); - layoutOptions.push_back({layout, layoutEntry.first}); + layoutOptions.emplace_back(layout, layoutEntry.first); } } } // namespace app::bell_settings diff --git a/products/BellHybrid/apps/common/include/common/layouts/BaseHomeScreenLayoutProvider.hpp b/products/BellHybrid/apps/common/include/common/layouts/BaseHomeScreenLayoutProvider.hpp index 6dbd1e70b3e10fd9542f75288143c62691f4b02d..46dba7ba52723d666d7322c27e19161423df4345 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/BaseHomeScreenLayoutProvider.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/BaseHomeScreenLayoutProvider.hpp @@ -27,7 +27,7 @@ namespace app::home_screen AlarmSnoozed, PreWakeUpActive }; -}; +} namespace gui { @@ -40,7 +40,7 @@ namespace gui std::string name; public: - BaseHomeScreenLayoutProvider(std::string name) : name{std::move(name)} {}; + explicit BaseHomeScreenLayoutProvider(std::string name) : name{std::move(name)} {}; virtual ~BaseHomeScreenLayoutProvider() noexcept = default; std::string getName() @@ -54,7 +54,7 @@ namespace gui virtual void updateUsbStatus(bool isConnected) = 0; virtual void setTime(std::time_t newTime) = 0; virtual void setAlarmTimeFormat(utils::time::Locale::TimeFormat fmt) = 0; - virtual std::time_t getAlarmTime() const = 0; + [[nodiscard]] virtual std::time_t getAlarmTime() const = 0; virtual void setAlarmTime(std::time_t newTime) = 0; virtual SnoozeTimer *getSnoozeTimer() = 0; virtual Item *getLayout() = 0; @@ -65,4 +65,4 @@ namespace gui virtual void setSnoozeTime(std::time_t newTime){}; virtual void setQuoteText(const UTF8 "eContent, const UTF8 "eAuthor){}; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassic.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassic.hpp index cb908f5aa142035db9dd7ad447d4c2a6f581a30b..0acfb2075b7a03a5eb0476e2224c401eecaa4cb2 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassic.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassic.hpp @@ -9,16 +9,15 @@ namespace style::homescreen_classic { - constexpr inline auto status_box_layout_w = 350U; - constexpr inline auto info_box_layout_h = 70U; - constexpr inline auto connection_box_layout_h = 44U; - constexpr inline auto connection_box_top_margin = 20U; - constexpr inline auto connection_box_bottom_margin = -20; - + inline constexpr auto status_box_layout_w{350U}; + inline constexpr auto info_box_layout_h{70U}; + inline constexpr auto connection_box_layout_h{44U}; + inline constexpr auto connection_box_top_margin{20U}; + inline constexpr auto connection_box_bottom_margin{-20}; } // namespace style::homescreen_classic + namespace gui { - class BellBaseLayout; class TextFixedSize; class AlarmSetSpinner; @@ -54,20 +53,19 @@ namespace gui class HomeScreenLayoutClassic : public BaseHomeScreenLayoutProvider, protected BellBaseLayout { public: - HomeScreenLayoutClassic(std::string name); + explicit HomeScreenLayoutClassic(std::string name); - virtual auto setViewState(app::home_screen::ViewState state) -> void override; - virtual auto setTime(std::time_t newTime) -> void override; + auto setViewState(app::home_screen::ViewState state) -> void override; + auto setTime(std::time_t newTime) -> void override; auto setTextDescription(const UTF8 &desc) -> void override; auto setBatteryLevelState(const Store::Battery &batteryContext) -> void override; auto setTimeFormat(utils::time::Locale::TimeFormat fmt) -> void override; auto setAlarmTimeFormat(utils::time::Locale::TimeFormat fmt) -> void override; auto setSnoozeFormat(utils::time::Locale::TimeFormat fmt) -> void override; - auto getAlarmTime() const -> std::time_t override; + [[nodiscard]] auto getAlarmTime() const -> std::time_t override; auto setAlarmTime(std::time_t newTime) -> void override; auto setSnoozeTime(std::time_t newTime) -> void override; auto updateUsbStatus(bool isConnected) -> void override; - auto setQuoteText(const UTF8 "eContent, const UTF8 "eAuthor) -> void override; auto getSnoozeTimer() -> SnoozeTimer * override; auto getLayout() -> Item * override; @@ -83,20 +81,20 @@ namespace gui void adjustConnectionStatusPosition(); protected: - VBox *widgetBox = nullptr; - HBox *timeHBox = nullptr; - TimeSetFmtSpinner *time = nullptr; - HBox *statusBox = nullptr; - HBox *infoBox = nullptr; - HBox *connectionBox = nullptr; - BellBattery *battery = nullptr; - BellConnectionStatus *connectionStatus = nullptr; - TextFixedSize *bottomText = nullptr; - AlarmSetSpinner *alarm = nullptr; - SnoozeTimer *snoozeTimer = nullptr; - Icon *lowBatteryWarning = nullptr; + VBox *widgetBox{nullptr}; + HBox *timeHBox{nullptr}; + TimeSetFmtSpinner *time{nullptr}; + HBox *statusBox{nullptr}; + HBox *infoBox{nullptr}; + HBox *connectionBox{nullptr}; + BellBattery *battery{nullptr}; + BellConnectionStatus *connectionStatus{nullptr}; + TextFixedSize *bottomText{nullptr}; + AlarmSetSpinner *alarm{nullptr}; + SnoozeTimer *snoozeTimer{nullptr}; + Icon *lowBatteryWarning{nullptr}; std::function onShowMessage; std::function onHideMessage; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithAmPm.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithAmPm.hpp index 169afe1c7698ee1755bd50de78812f243f5fe262..4d957a156adec0c0dfcea6e3c3a15ace1efe02a4 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithAmPm.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithAmPm.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -10,7 +10,7 @@ namespace gui class HomeScreenLayoutClassicWithAmPm : public HomeScreenLayoutClassic { public: - HomeScreenLayoutClassicWithAmPm(std::string name); + explicit HomeScreenLayoutClassicWithAmPm(std::string name); auto setTime(std::time_t newTime) -> void override; @@ -21,4 +21,4 @@ namespace gui TextFixedSize *fmt{}; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithBattery.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithBattery.hpp index 5951ee1ea476d88f367ce992f2227fd8f7ac5bf4..12c5bb54bc37345e61120e6e6111dbd9b996cc6b 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithBattery.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithBattery.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -10,9 +10,9 @@ namespace gui class HomeScreenLayoutClassicWithBattery : public HomeScreenLayoutClassic { public: - HomeScreenLayoutClassicWithBattery(std::string name); + explicit HomeScreenLayoutClassicWithBattery(std::string name); protected: bool isBatteryVisibilityAllowed(const Store::Battery &batteryContext) override; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithDate.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithDate.hpp index c94f0a009893ed0f50aabd0b77e0a1df533440db..75189f7b37cfcbc1f12a3edb5cef8d235dc181b2 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithDate.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithDate.hpp @@ -10,7 +10,7 @@ namespace gui class HomeScreenLayoutClassicWithDate : public HomeScreenLayoutClassic { public: - HomeScreenLayoutClassicWithDate(std::string name); + explicit HomeScreenLayoutClassicWithDate(std::string name); void setTime(std::time_t newTime) override; void setTimeFormat(utils::time::Locale::TimeFormat fmt) override; @@ -19,8 +19,7 @@ namespace gui void buildInterface() override; bool isBatteryVisibilityAllowed(const Store::Battery &batteryContext) override; - Text *date = nullptr; - TextFixedSize *ampm = nullptr; - bool showAMPM = false; + Text *date{nullptr}; + TextFixedSize *ampm{nullptr}; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithQuotes.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithQuotes.hpp index 6ba12cc6c2a0559764032d14a25ba8bf0afd00a8..e9e56e452618b80babdd40ed3a6b81ee40b2b187 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithQuotes.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithQuotes.hpp @@ -27,4 +27,4 @@ namespace gui void hideQuotes(); void adjustWidgetBox(); }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithQuotesAmPm.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithQuotesAmPm.hpp index 5b97f11bad0e5c8441ec2fd10068de379dc51130..e62f1598276372e157357a5658b57c75ff4ab9e2 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithQuotesAmPm.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithQuotesAmPm.hpp @@ -20,4 +20,4 @@ namespace gui TextFixedSize *ampm{nullptr}; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithTemp.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithTemp.hpp index 0dafd18e84f81411cf2d8e88125cb8ad5a1d52f2..25f1b6e53da6c6eee4277a25c1c2bdc9bc62d7a2 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithTemp.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithTemp.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -7,23 +7,22 @@ namespace style::homescreen_classic { - constexpr inline auto temperature_w = 170U; - constexpr inline auto temperature_h = 102U; + inline constexpr auto temperature_w{170U}; + inline constexpr auto temperature_h{102U}; } // namespace style::homescreen_classic namespace gui { - class HomeScreenLayoutClassicWithTemp : public HomeScreenLayoutClassic { public: - HomeScreenLayoutClassicWithTemp(std::string name); + explicit HomeScreenLayoutClassicWithTemp(std::string name); auto setTemperature(utils::temperature::Temperature newTemp) -> void override; protected: auto buildInterface() -> void override; - TextFixedSize *tempText{}; + TextFixedSize *tempText{nullptr}; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutNames.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutNames.hpp index 1c38c6641bdf8e2ff25584d4f35a0b92d58fad28..96c422cb48901e884b88d23551d1f3af87436bb0 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutNames.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutNames.hpp @@ -3,24 +3,22 @@ #pragma once -namespace gui +#include + +namespace gui::layout { - namespace layout - { - constexpr auto Classic = "Classic"; - constexpr auto ClassicWithBattery = "ClassicWithBattery"; - constexpr auto ClassicWithAmPm = "ClassicWithAmPm"; - constexpr auto ClassicWithDate = "ClassicWithDate"; - constexpr auto ClassicWithQuotes = "ClassicWithQuotes"; - constexpr auto ClassicWithQuotesAmPm = "ClassicWithQuotesAmPm"; - constexpr auto VerticalSimple = "VerticalSimple"; - constexpr auto VerticalWithDate = "VerticalWithDate"; - constexpr auto VerticalWithAmPm = "VerticalWithAmPm"; - constexpr auto VerticalWithDateAmPm = "VerticalWithDateAmPm"; + inline constexpr auto Classic = "Classic"; + inline constexpr auto ClassicWithBattery = "ClassicWithBattery"; + inline constexpr auto ClassicWithAmPm = "ClassicWithAmPm"; + inline constexpr auto ClassicWithDate = "ClassicWithDate"; + inline constexpr auto ClassicWithQuotes = "ClassicWithQuotes"; + inline constexpr auto ClassicWithQuotesAmPm = "ClassicWithQuotesAmPm"; + inline constexpr auto VerticalSimple = "VerticalSimple"; + inline constexpr auto VerticalWithDate = "VerticalWithDate"; + inline constexpr auto VerticalWithAmPm = "VerticalWithAmPm"; + inline constexpr auto VerticalWithDateAmPm = "VerticalWithDateAmPm"; #if CONFIG_ENABLE_TEMP == 1 - constexpr auto ClassicWithTemp = "ClassicWithTemp"; + inline constexpr auto ClassicWithTemp = "ClassicWithTemp"; #endif - - } // namespace layout } // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp index b1f7a1cc3c25b27b4702ddf26d5fbd7cb67ec189..c267299962433e588378017cdc658cffbfed9eb5 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp @@ -11,7 +11,6 @@ namespace gui { - class BellBaseLayout; class TextFixedSize; class AlarmIcon; @@ -34,15 +33,15 @@ namespace gui class HomeScreenLayoutVertical : public BaseHomeScreenLayoutProvider, public LayoutVertical { public: - HomeScreenLayoutVertical(std::string name); + explicit HomeScreenLayoutVertical(std::string name); - virtual auto setViewState(app::home_screen::ViewState state) -> void override; - virtual auto setTime(std::time_t newTime) -> void override; + auto setViewState(app::home_screen::ViewState state) -> void override; + auto setTime(std::time_t newTime) -> void override; auto setTextDescription(const UTF8 &desc) -> void override; auto setBatteryLevelState(const Store::Battery &batteryContext) -> void override; auto setTimeFormat(utils::time::Locale::TimeFormat fmt) -> void override; auto setAlarmTimeFormat(utils::time::Locale::TimeFormat fmt) -> void override; - auto getAlarmTime() const -> std::time_t override; + [[nodiscard]] auto getAlarmTime() const -> std::time_t override; auto setAlarmTime(std::time_t newTime) -> void override; auto updateUsbStatus(bool isConnected) -> void override; void setQuoteText(const UTF8 "eContent, const UTF8 "eAuthor) override; @@ -54,6 +53,6 @@ namespace gui auto setScreenMode(ScreenMode mode) -> void; virtual bool isBatteryVisibilityAllowed(const Store::Battery &batteryContext); virtual bool isAlarmTimeVisibilityAllowed(); - bool isBatteryCharging(const Store::Battery::State state); + bool isBatteryCharging(Store::Battery::State state); }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalSimple.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalSimple.hpp index 4feea0e31ef88b7f2dc699f908334cc327a82f05..c7172e98a93a8579bb93b3a5a32b59fad9057c51 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalSimple.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalSimple.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -11,6 +11,6 @@ namespace gui class HomeScreenLayoutVerticalSimple : public HomeScreenLayoutVertical { public: - HomeScreenLayoutVerticalSimple(std::string name); + explicit HomeScreenLayoutVerticalSimple(std::string name); }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithAmPm.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithAmPm.hpp index 2eb05433fd77460a4e381d329057be8e4f19c6a8..04e98f0c4d043f21e03fd99a04ebe4bdf680acbc 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithAmPm.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithAmPm.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -7,9 +7,9 @@ namespace style::homescreen_vertical_ampm { - constexpr inline auto alarm_margin_top = 83U; - constexpr inline auto battery_margin_bot = 68U; - constexpr inline auto ampm_margin_bot = 77U; + inline constexpr auto alarm_margin_top{83U}; + inline constexpr auto battery_margin_bot{68U}; + inline constexpr auto ampm_margin_bot{77U}; } // namespace style::homescreen_vertical_ampm namespace gui @@ -24,4 +24,4 @@ namespace gui TextFixedSize *ampm{}; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp index a921b5fb44d68b407b33c7171e552fbe31bb3801..c3cedff908e6db79777e0af35c56598b447ed0cb 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -7,17 +7,16 @@ namespace style::homescreen_vertical_date { - constexpr inline auto margin_top = 64U; - constexpr inline auto margin_bot = 70U; + inline constexpr auto margin_top{64U}; + inline constexpr auto margin_bot{70U}; } // namespace style::homescreen_vertical_date namespace gui { - class HomeScreenLayoutVerticalWithDate : public HomeScreenLayoutVertical { public: - HomeScreenLayoutVerticalWithDate(std::string name); + explicit HomeScreenLayoutVerticalWithDate(std::string name); void setTime(std::time_t newTime) override; void setTimeFormat(utils::time::Locale::TimeFormat fmt) override; @@ -29,4 +28,4 @@ namespace gui TextFixedSize *ampm = nullptr; TextFixedSize *date = nullptr; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayouts.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayouts.hpp index 14761c0093792022578d82395d84f6f16704331e..1233a502aedc6a1c6a7ee1978322a760d71feb2b 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayouts.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayouts.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -20,4 +20,4 @@ namespace gui std::map getAllLayouts(); std::string getDefaultLayout(); } // namespace factory -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/ShortcutsLayoutProvider.hpp b/products/BellHybrid/apps/common/include/common/layouts/ShortcutsLayoutProvider.hpp index 172d54001ea7968c5ba687030156467563db3bd3..58a5ad19bfa8237d3c7dfc7664557cc123942d7a 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/ShortcutsLayoutProvider.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/ShortcutsLayoutProvider.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -27,4 +27,4 @@ namespace gui virtual Item *getLayout() = 0; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/ShortcutsLayouts.hpp b/products/BellHybrid/apps/common/include/common/layouts/ShortcutsLayouts.hpp index a3ace42f9be140a70ed838c5266efd607c461ce3..be9dcc077e05f970c5b1812195b4f504015f7659 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/ShortcutsLayouts.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/ShortcutsLayouts.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -10,10 +10,11 @@ namespace gui { class ShortcutsLayoutProvider; + using LayoutGenerator = std::function; namespace factory { std::vector getLayouts(); } // namespace factory -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutClassic.hpp b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutClassic.hpp index 0c67d05d806c4b1f78242341e539dad7037f2f63..33758c2df26c969b9ec6ab1136245a2970452940 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutClassic.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutClassic.hpp @@ -40,4 +40,4 @@ namespace gui auto buildInterface(const Instruction &instruction) -> void; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutProvider.hpp b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutProvider.hpp index 393d315757cbc26622f7ef5941dbe5b837013461..3929d34bdc68d2d1b4047022949c06b9c675ef9a 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutProvider.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayoutProvider.hpp @@ -27,4 +27,4 @@ namespace gui virtual Item *getLayout() = 0; }; -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayouts.hpp b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayouts.hpp index 3d4e3f63829890ec95eba76d6d29196198fb1f27..5b38cbebf4f744e8622807fd056e3fd8d876278e 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayouts.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/UpdateInstructionLayouts.hpp @@ -10,10 +10,11 @@ namespace gui { class UpdateInstructionLayoutProvider; + using LayoutGenerator = std::function; namespace factory { std::vector getUpdateInstructionLayouts(); } // namespace factory -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp index 7d1f68e5d4c4d13444b5e6e4ef460712e526d98a..287baa6eb4677553c0101c12def6963001d04522 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp @@ -20,7 +20,7 @@ namespace { - constexpr auto dischargingLevelShowTop = 20; + constexpr auto dischargingLevelShowTop{20}; bool isBatteryCharging(const Store::Battery::State state) { @@ -406,8 +406,4 @@ namespace gui } } } - - auto HomeScreenLayoutClassic::setQuoteText(const UTF8 "eContent, const UTF8 "eAuthor) -> void - {} - -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithAmPm.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithAmPm.cpp index b63af52d6b7dcef828d125a1b2c88adb11cbb81c..cbf2448b380f2654a429c8acf739e0ce529863aa 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithAmPm.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithAmPm.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "layouts/HomeScreenLayoutClassicWithAmPm.hpp" @@ -65,4 +65,4 @@ namespace gui } HomeScreenLayoutClassic::handleContentChanged(); } -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithBattery.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithBattery.cpp index 77d3422236ed87e3e2c3adc7c1741c4bde2ef21b..d333053dfa2a25fcbd7df6863d294c4c37c37c7c 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithBattery.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithBattery.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include @@ -14,4 +14,4 @@ namespace gui { return true; } -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithDate.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithDate.cpp index 65a00c16268437db66f64436a4fad903e561e839..fd72b5b2371579b6038d1e9e3db2de923c9c373e 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithDate.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithDate.cpp @@ -86,4 +86,4 @@ namespace gui { return true; } -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithQuotesAmPm.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithQuotesAmPm.cpp index bec3ac7de0b347fd03f972c971d675f8d95a43da..f02a61d9c8acedd1e946ca221b7a5b82f4faf0df 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithQuotesAmPm.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithQuotesAmPm.cpp @@ -58,5 +58,4 @@ namespace gui ampm->setVisible(false); } } - -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithTemp.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithTemp.cpp index c5eec038d7064eb29030df9dc1e637d98753dcda..ffb4b2dc8b0ad4d93e03854047bb937c504aff22 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithTemp.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithTemp.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "layouts/HomeScreenLayoutClassicWithTemp.hpp" @@ -20,17 +20,21 @@ namespace gui { using namespace bellMainStyle; - tempText = new TextFixedSize(statusBox); + tempText = new TextFixedSize(nullptr); tempText->setMaximumSize(style::homescreen_classic::temperature_w, style::homescreen_classic::temperature_h); + tempText->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); tempText->setFont(mainWindow::bottomDescription::font_normal); tempText->setEdges(RectangleEdge::None); tempText->activeItem = false; tempText->drawUnderline(false); + tempText->setMargins(Margins(0, style::bell_base_layout::info_box_top_margin, 0, 0)); + + infoBox->addWidget(tempText); } auto HomeScreenLayoutClassicWithTemp::setTemperature(utils::temperature::Temperature newTemp) -> void { tempText->setText(utils::temperature::tempToStrDec(newTemp)); - statusBox->resizeItems(); + infoBox->resizeItems(); } -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp index ab4a9af6302389fc5f063289998ff8df9dba4fa9..94dbe3d36f9c858de752821d99ff8896b6dff033 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp @@ -18,7 +18,7 @@ namespace { - constexpr auto dischargingLevelShowTop = 20; + constexpr auto dischargingLevelShowTop{20}; } // namespace namespace gui @@ -158,7 +158,7 @@ namespace gui return false; } - bool HomeScreenLayoutVertical::isBatteryCharging(const Store::Battery::State state) + bool HomeScreenLayoutVertical::isBatteryCharging(Store::Battery::State state) { using State = Store::Battery::State; return (state == State::Charging) || (state == State::ChargingDone); @@ -212,5 +212,4 @@ namespace gui connectionStatus->show(isConnected); connectionStatus->informContentChanged(); } - -}; // namespace gui +} // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalSimple.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalSimple.cpp index 1c8ab9f2f4635e25cde3fd27a7324752841b8ce8..444d988c4741ccc1f215d90d8b2189dd3039566d 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalSimple.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalSimple.cpp @@ -1,10 +1,9 @@ -// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "layouts/HomeScreenLayoutVerticalSimple.hpp" #include "data/BellMainStyle.hpp" #include "widgets/BellBattery.hpp" -#include "widgets/DuoHBox.hpp" #include "widgets/SnoozeTimer.hpp" #include @@ -12,7 +11,6 @@ #include #include #include -#include