~aleteoryx/muditaos

9ff36a172234fcc90d334649393a573afb8e200f — Mateusz Grzegorzek 4 years ago 2150134
[BH-835] Add Alarm Settings menu window

Add alarm settings options in `BellSettingsAlarmSettingsWindow`
M image/assets/lang/English.json => image/assets/lang/English.json +3 -0
@@ 571,6 571,9 @@
  "app_bell_settings_advanced_time_units": "Time & units",
  "app_bell_settings_advanced_temp_scale": "Temperature scale",
  "app_bell_settings_alarm_settings": "Alarm settings",
  "app_bell_settings_alarm_settings_prewake_up": "Pre-wake up",
  "app_bell_settings_alarm_settings_alarm_tone_and_light": "Alarm tone & light",
  "app_bell_settings_alarm_settings_snooze": "Snooze",
  "app_bell_settings_bedtime_tone": "Bedtime tone",
  "app_bell_settings_home_view": "Home view",
  "app_bell_settings_turn_off": "Turn off",

M products/BellHybrid/apps/application-bell-settings/data/BellSettingsStyle.hpp => products/BellHybrid/apps/application-bell-settings/data/BellSettingsStyle.hpp +6 -0
@@ 26,5 26,11 @@ namespace gui
        {
            inline constexpr auto font = "gt_pressura_light_46";
        }
        namespace alarm_settings_window
        {
            inline constexpr auto options_list_margin_x = 100U;
            inline constexpr auto options_list_margin_y = 110U;
            inline constexpr auto default_body_width    = 400U;
        } // namespace alarm_settings_window
    } // namespace bell_settings_style
} // namespace gui

M products/BellHybrid/apps/application-bell-settings/include/application-bell-settings/ApplicationBellSettings.hpp => products/BellHybrid/apps/application-bell-settings/include/application-bell-settings/ApplicationBellSettings.hpp +13 -10
@@ 8,16 8,19 @@

namespace gui::window::name
{
    inline constexpr auto bellSettings              = "BellSettings";
    inline constexpr auto bellSettingsAdvanced      = "BellSettingsAdvanced";
    inline constexpr auto bellSettingsTimeUnits     = "BellSettingsTimeUnits";
    inline constexpr auto bellSettingsDialog        = "BellSettingsDialog";
    inline constexpr auto bellSettingsFinished      = "BellSettingsFinished";
    inline constexpr auto bellSettingsFrontlight    = "BellSettingsFrontlight";
    inline constexpr auto bellSettingsHomeView      = "BellSettingsHomeView";
    inline constexpr auto bellSettingsAlarmSettings = "BellSettingsAlarmSettings";
    inline constexpr auto bellSettingsBedtimeTone   = "BellSettingsBedtimeTone";
    inline constexpr auto bellSettingsTurnOff       = "BellSettingsTurnOff";
    inline constexpr auto bellSettings                               = "BellSettings";
    inline constexpr auto bellSettingsAdvanced                       = "BellSettingsAdvanced";
    inline constexpr auto bellSettingsTimeUnits                      = "BellSettingsTimeUnits";
    inline constexpr auto bellSettingsDialog                         = "BellSettingsDialog";
    inline constexpr auto bellSettingsFinished                       = "BellSettingsFinished";
    inline constexpr auto bellSettingsFrontlight                     = "BellSettingsFrontlight";
    inline constexpr auto bellSettingsHomeView                       = "BellSettingsHomeView";
    inline constexpr auto bellSettingsAlarmSettings                  = "BellSettingsAlarmSettings";
    inline constexpr auto bellSettingsAlarmSettingsPrewakeUp         = "BellSettingsAlarmSettingsPrewakeUp";
    inline constexpr auto bellSettingsAlarmSettingsAlarmToneAndLight = "BellSettingsAlarmSettingsAlarmToneAndLight";
    inline constexpr auto bellSettingsAlarmSettingsSnooze            = "BellSettingsAlarmSettingsSnooze";
    inline constexpr auto bellSettingsBedtimeTone                    = "BellSettingsBedtimeTone";
    inline constexpr auto bellSettingsTurnOff                        = "BellSettingsTurnOff";
} // namespace gui::window::name

namespace app

M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsAlarmSettingsWindow.cpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsAlarmSettingsWindow.cpp +44 -2
@@ 4,12 4,16 @@
#include "BellSettingsAlarmSettingsWindow.hpp"

#include <application-bell-settings/ApplicationBellSettings.hpp>
#include <apps-common/messages/DialogMetadataMessage.hpp>
#include <apps-common/options/type/OptionBellMenu.hpp>
#include <data/BellSettingsStyle.hpp>

namespace gui
{
    BellSettingsAlarmSettingsWindow::BellSettingsAlarmSettingsWindow(app::Application *app, std::string name)
        : OptionWindow(app, std::move(name))
    {
        addOptions(alarmSettingsOptionsList());
        buildInterface();
    }



@@ 21,9 25,47 @@ namespace gui

    void BellSettingsAlarmSettingsWindow::buildInterface()
    {
        AppWindow::buildInterface();
        header->setTitle(title);
        header->setEdges(RectangleEdge::None);
        statusBar->setVisible(false);
        header->setTitleVisibility(false);
        bottomBar->setVisible(false);

        optionsList->setPosition(bell_settings_style::alarm_settings_window::options_list_margin_x,
                                 bell_settings_style::alarm_settings_window::options_list_margin_y);
        optionsList->setMaximumWidth(bell_settings_style::alarm_settings_window::default_body_width);
        optionsList->setBoundaries(gui::Boundaries::Fixed);
    }

    std::list<Option> BellSettingsAlarmSettingsWindow::alarmSettingsOptionsList()
    {
        std::list<gui::Option> alarmSettingsOptionsList;
        auto addAlarmSettingsOption = [&](const UTF8 &name, const std::string &window) {
            alarmSettingsOptionsList.emplace_back(std::make_unique<gui::option::OptionBellMenu>(
                name,
                [=](gui::Item &item) {
                    if (window.empty()) {
                        return false;
                    }
                    application->switchWindow(
                        window,
                        gui::ShowMode::GUI_SHOW_INIT,
                        std::make_unique<gui::DialogMetadataMessage>(gui::DialogMetadata{name, "search_big", " "}));
                    return true;
                },
                [=](gui::Item &item) {
                    // put focus change callback here
                    return true;
                },
                this));
        };

        addAlarmSettingsOption(utils::translate("app_bell_settings_alarm_settings_prewake_up"),
                               gui::window::name::bellSettingsAlarmSettingsPrewakeUp);
        addAlarmSettingsOption(utils::translate("app_bell_settings_alarm_settings_alarm_tone_and_light"),
                               gui::window::name::bellSettingsAlarmSettingsAlarmToneAndLight);
        addAlarmSettingsOption(utils::translate("app_bell_settings_alarm_settings_snooze"),
                               gui::window::name::bellSettingsAlarmSettingsSnooze);

        return alarmSettingsOptionsList;
    }
} /* namespace gui */

M products/BellHybrid/apps/application-bell-settings/windows/BellSettingsAlarmSettingsWindow.hpp => products/BellHybrid/apps/application-bell-settings/windows/BellSettingsAlarmSettingsWindow.hpp +4 -0
@@ 15,6 15,10 @@ namespace gui
        explicit BellSettingsAlarmSettingsWindow(app::Application *app,
                                                 std::string name = gui::window::name::bellSettingsAlarmSettings);

      private:
        static constexpr auto title = "Alarm settings";

        std::list<Option> alarmSettingsOptionsList();
        void buildInterface() override;
        void rebuild() override;
    };