~aleteoryx/muditaos

4bc7df5f4ae774dc87178eec2bd856600b617f0a — Tomek Sobkowiak 5 years ago 2a83401
[EDG-4049] Add locked screen settings window with ON/OFF (#900)

* [EDG-4206] Add locked screen and integrate with ON/OFF widget
36 files changed, 671 insertions(+), 443 deletions(-)

M image/assets/lang/lang_en.json
A image/data/applications/settings/quotes.json
M module-apps/application-settings-new/ApplicationSettings.cpp
M module-apps/application-settings-new/ApplicationSettings.hpp
M module-apps/application-settings-new/CMakeLists.txt
M module-apps/application-settings-new/widgets/SettingsStyle.hpp
D module-apps/application-settings-new/widgets/Toggle.cpp
D module-apps/application-settings-new/widgets/Toggle.hpp
D module-apps/application-settings-new/widgets/UpDown.cpp
D module-apps/application-settings-new/widgets/UpDown.hpp
M module-apps/application-settings-new/windows/AllDevicesWindow.cpp
A module-apps/application-settings-new/windows/AutolockWindow.cpp
A module-apps/application-settings-new/windows/AutolockWindow.hpp
M module-apps/application-settings-new/windows/BaseSettingsWindow.cpp
M module-apps/application-settings-new/windows/BaseSettingsWindow.hpp
M module-apps/application-settings-new/windows/DisplayAndKeypadWindow.cpp
M module-apps/application-settings-new/windows/DisplayLightWindow.cpp
M module-apps/application-settings-new/windows/DisplayLightWindow.hpp
M module-apps/application-settings-new/windows/FontSizeWindow.cpp
M module-apps/application-settings-new/windows/FontSizeWindow.hpp
M module-apps/application-settings-new/windows/InputLanguageWindow.cpp
M module-apps/application-settings-new/windows/InputLanguageWindow.hpp
M module-apps/application-settings-new/windows/KeypadLightWindow.cpp
M module-apps/application-settings-new/windows/KeypadLightWindow.hpp
M module-apps/application-settings-new/windows/LockedScreenWindow.cpp
M module-apps/application-settings-new/windows/LockedScreenWindow.hpp
A module-apps/application-settings-new/windows/QuotesAddWindow.cpp
A module-apps/application-settings-new/windows/QuotesAddWindow.hpp
A module-apps/application-settings-new/windows/QuotesMainWindow.cpp
A module-apps/application-settings-new/windows/QuotesMainWindow.hpp
A module-apps/application-settings-new/windows/WallpaperWindow.cpp
A module-apps/application-settings-new/windows/WallpaperWindow.hpp
M module-apps/windows/OptionSetting.cpp
M module-apps/windows/OptionSetting.hpp
M module-gui/gui/widgets/CheckBoxWithLabel.cpp
M module-gui/gui/widgets/CheckBoxWithLabel.hpp
M image/assets/lang/lang_en.json => image/assets/lang/lang_en.json +10 -2
@@ 249,10 249,18 @@
    "app_settings_display_font_size": "Font size",
    "app_settings_display_locked_screen": "Locked screen",
    "app_settings_display_keypad_light": "Keypad light",
    "app_settings_display_keypad_light_on": "On",
    "app_settings_display_keypad_light_active": "When active",
    "app_settings_display_keypad_light_on": "Always on",
    "app_settings_display_keypad_light_active": "On when active",
    "app_settings_display_keypad_light_off": "Off",
    "app_settings_display_input_language": "Input language",
    "app_settings_display_locked_screen_autolock": "Autolock" ,
    "app_settings_display_locked_screen_wallpaper": "Wallpaper",
    "app_settings_display_locked_screen_quotes": "Quotes",
    "app_settings_display_locked_screen_new_quote": "New quote",
    "app_settings_display_wallpaper_logo": "Mudita logo",
    "app_settings_display_wallpaper_clock": "Clock",
    "app_settings_display_wallpaper_quotes": "Quotes",
    "app_settings_display_wallpaper_select_quotes": "Select Quotes",
    "app_settings_system" : "System",
    "app_settings_apps_tools" : "Apps and tools",
    "app_settings_apps_messages" : "Messages",

A image/data/applications/settings/quotes.json => image/data/applications/settings/quotes.json +27 -0
@@ 0,0 1,27 @@
[
  {
    "lang":"english",
    "author": "Buddha",
    "quote": "Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment."
  },
  {
    "lang":"english",
    "author": "Tara Brach",
    "quote": "The only way to live is by accepting each minute as an unrepeatable miracle."
  },
  {
    "lang":"english",
    "author": "Richar Bach",
    "quote": "The simplest things are often the truest"
  },
  {
    "lang":"english",
    "author": "Eckhart Tolle",
    "quote": "Always say yes to the present moment. Say yes to life."
  },
  {
    "lang":"english",
    "author": "Naomi Judd",
    "quote": "Slow down, simplify and be kind"
  }
]

M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +16 -0
@@ 17,6 17,10 @@
#include "windows/NetworkWindow.hpp"
#include "windows/MessagesWindow.hpp"
#include "windows/PhoneNameWindow.hpp"
#include "windows/AutolockWindow.hpp"
#include "windows/WallpaperWindow.hpp"
#include "windows/QuotesMainWindow.hpp"
#include "windows/QuotesAddWindow.hpp"

#include "Dialog.hpp"



@@ 119,6 123,18 @@ namespace app
        windowsFactory.attach(gui::window::name::phone_name, [](Application *app, const std::string &name) {
            return std::make_unique<gui::PhoneNameWindow>(app);
        });
        windowsFactory.attach(gui::window::name::autolock, [](Application *app, const std::string &name) {
            return std::make_unique<gui::AutolockWindow>(app);
        });
        windowsFactory.attach(gui::window::name::wallpaper, [](Application *app, const std::string &name) {
            return std::make_unique<gui::WallpaperWindow>(app);
        });
        windowsFactory.attach(gui::window::name::quotes, [](Application *app, const std::string &name) {
            return std::make_unique<gui::QuotesMainWindow>(app);
        });
        windowsFactory.attach(gui::window::name::new_quote, [](Application *app, const std::string &name) {
            return std::make_unique<gui::QuotesAddWindow>(app);
        });
    }

    void ApplicationSettingsNew::destroyUserInterface()

M module-apps/application-settings-new/ApplicationSettings.hpp => module-apps/application-settings-new/ApplicationSettings.hpp +5 -0
@@ 30,6 30,11 @@ namespace gui::window::name
    inline const std::string torch     = "Torch";
    inline const std::string templates = "Templates";

    inline const std::string autolock  = "Autolock";
    inline const std::string wallpaper = "Wallpaper";
    inline const std::string quotes    = "Quotes";
    inline const std::string new_quote = "NewQuote";

    inline const std::string display_and_keypad = "DisplayAndKeypad";

    inline const std::string change_settings = "ChangeSettings";

M module-apps/application-settings-new/CMakeLists.txt => module-apps/application-settings-new/CMakeLists.txt +6 -4
@@ 30,8 30,10 @@ target_sources( ${PROJECT_NAME}
        windows/NetworkWindow.cpp
        windows/MessagesWindow.cpp
        windows/PhoneNameWindow.cpp
        widgets/UpDown.cpp
        widgets/Toggle.cpp
        windows/AutolockWindow.cpp
        windows/WallpaperWindow.cpp
        windows/QuotesMainWindow.cpp
        windows/QuotesAddWindow.cpp

    PUBLIC
        ApplicationSettings.hpp


@@ 46,8 48,8 @@ target_sources( ${PROJECT_NAME}
        windows/AppsAndToolsWindow.hpp
        windows/MessagesWindow.hpp
        widgets/SettingsStyle.hpp
        widgets/UpDown.hpp
        widgets/Toggle.hpp
        windows/AutolockWindow.hpp
        windows/WallpaperWindow.hpp
)

add_dependencies(${PROJECT_NAME} version)

M module-apps/application-settings-new/widgets/SettingsStyle.hpp => module-apps/application-settings-new/widgets/SettingsStyle.hpp +15 -19
@@ 11,25 11,21 @@ namespace style
    {
        namespace window
        {
            namespace allDevices
            namespace leftArrowImage
            {
                namespace leftArrowImage
                {
                    constexpr uint32_t x = style::window::default_left_margin;
                    constexpr uint32_t y = 62;
                    constexpr uint32_t w = 11;
                    constexpr uint32_t h = 13;
                } // namespace leftArrowImage
                constexpr uint32_t x = style::window::default_left_margin;
                constexpr uint32_t y = 62;
                constexpr uint32_t w = 11;
                constexpr uint32_t h = 13;
            } // namespace leftArrowImage

                namespace crossImage
                {
                    constexpr uint32_t x = style::window::default_left_margin + 20;
                    constexpr uint32_t y = 55;
                    constexpr uint32_t w = 24;
                    constexpr uint32_t h = 24;
                } // namespace crossImage
            }     // namespace allDevices

        }; // namespace window
    }      // namespace settings
            namespace crossImage
            {
                constexpr uint32_t x = style::window::default_left_margin + 20;
                constexpr uint32_t y = 55;
                constexpr uint32_t w = 24;
                constexpr uint32_t h = 24;
            } // namespace crossImage
        }     // namespace window
    };        // namespace settings
} // namespace style

D module-apps/application-settings-new/widgets/Toggle.cpp => module-apps/application-settings-new/widgets/Toggle.cpp +0 -54
@@ 1,54 0,0 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Toggle.hpp"

namespace gui
{
    Toggle::Toggle(Item *parent, int x, int y, int w, int h, UTF8 text, bool defaultState)
        : HBox(parent, x, y, w, h), text(std::move(text)), state(defaultState)
    {
        setEdges(gui::RectangleEdge::None);
        buildToggle();
    }

    void Toggle::doToggle()
    {
        state = !state;
        buildToggle();
    }

    bool Toggle::getState() const noexcept
    {
        return state;
    }

    void Toggle::buildToggle()
    {
        removeWidget(label);

        label = new gui::Label(nullptr,
                               0,
                               0,
                               style::window_width - (2 * style::window::default_left_margin) - toggle_width,
                               style::window::label::big_h,
                               text);
        label->setEdges(gui::RectangleEdge::None);
        label->activatedCallback = [this](Item &) {
            doToggle();
            return false;
        };

        UTF8 onOffText =
            state ? utils::localize.get("app_settings_toggle_on") : utils::localize.get("app_settings_toggle_off");

        indicator =
            new gui::Label(label, style::toggle::toggle_x, 0, toggle_width, style::window::label::big_h, onOffText);

        style::window::decorateOption(label);
        style::window::decorate(indicator);

        addWidget(label);
        setVisible(true);
    }
}; // namespace gui

D module-apps/application-settings-new/widgets/Toggle.hpp => module-apps/application-settings-new/widgets/Toggle.hpp +0 -39
@@ 1,39 0,0 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <BoxLayout.hpp>
#include <i18/i18.hpp>
#include <utf8/UTF8.hpp>
#include <Label.hpp>

namespace style::toggle
{
    const gui::Position toggle_x = 408;
    const gui::Position toggle_y = 24;
} // namespace style::toggle

namespace gui
{
    class Toggle : public HBox
    {
      public:
        Toggle(Item *parent, int x, int y, int w, int h, UTF8 text, bool defaultState);
        ~Toggle() override = default;

        void doToggle();
        bool getState() const noexcept;

      private:
        void buildToggle();

        UTF8 text;

        Label *label     = nullptr;
        Label *indicator = nullptr;

        bool state;
        static constexpr uint toggle_width = 40;
    };
} // namespace gui

D module-apps/application-settings-new/widgets/UpDown.cpp => module-apps/application-settings-new/widgets/UpDown.cpp +0 -75
@@ 1,75 0,0 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "UpDown.hpp"

#include <Label.hpp>
#include <Image.hpp>

namespace gui
{
    UpDown::UpDown(Item *parent, int x, int y, int w, int h, UTF8 name, uint32_t defaultValue, uint32_t max)
        : HBox(parent, x, y, w, h), value(defaultValue), maxValue(max)
    {
        setEdges(gui::RectangleEdge::None);
        build(name);
    }

    void UpDown::build(UTF8 text)
    {
        removeWidget(label);

        label = new gui::Label(nullptr,
                               0,
                               0,
                               style::window_width - style::window::default_right_margin,
                               style::window::label::big_h,
                               text);
        label->setEdges(gui::RectangleEdge::None);
        style::window::decorateOption(label);

        progress = new ProgressBar(label,
                                   label->getWidth() - progress_width - style::window::default_right_margin,
                                   (label->getHeight() / 2) - (style::window::label::small_h / 2),
                                   progress_width,
                                   style::window::label::small_h);
        progress->setMaximum(maxValue);
        progress->setPercentageValue(value);

        auto leftArrow  = new Image(label,
                                   label->getWidth() / 2,
                                   (label->getHeight() / 2),
                                   style::window::label::small_h,
                                   style::window::label::small_h,
                                   "left_label_arrow");
        auto rightArrow = new Image(label,
                                    label->getWidth() / 2 + leftArrow->getWidth() + style::margins::small,
                                    (label->getHeight() / 2),
                                    style::window::label::small_h,
                                    style::window::label::small_h,
                                    "right_label_arrow");

        style::window::decorate(leftArrow);
        style::window::decorate(rightArrow);

        inputCallback = [this](Item &item, const InputEvent &event) { return setValueOnInput(event); };

        addWidget(label);
        setVisible(true);
    }

    auto UpDown::setValueOnInput(const InputEvent &event) -> bool
    {
        if (event.keyCode == KeyCode::KEY_RIGHT) {
            value += (value < maxValue) ? 1 : 0;
            progress->setPercentageValue(value);
            return true;
        }
        if (event.keyCode == KeyCode::KEY_LEFT) {
            value -= (value > 0) ? 1 : 0;
            progress->setPercentageValue(value);
            return true;
        }
        return false;
    }
} // namespace gui

D module-apps/application-settings-new/widgets/UpDown.hpp => module-apps/application-settings-new/widgets/UpDown.hpp +0 -42
@@ 1,42 0,0 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <i18/i18.hpp>
#include <BoxLayout.hpp>
#include <InputEvent.hpp>
#include <ProgressBar.hpp>
#include <utf8/UTF8.hpp>

namespace gui
{

    class UpDown : public HBox
    {
      public:
        UpDown(Item *parent,
               int x,
               int y,
               int w,
               int h,
               UTF8 name,
               uint32_t defaultValue,
               uint32_t max = std::numeric_limits<int>::max());

        ~UpDown() override = default;

        void build(UTF8 text);

      private:
        auto setValueOnInput(const InputEvent &event) -> bool;

        Label *label;
        Progress *progress;
        uint32_t value;
        uint32_t maxValue;

        static constexpr uint progress_width = 60;
    };

} // namespace gui

M module-apps/application-settings-new/windows/AllDevicesWindow.cpp => module-apps/application-settings-new/windows/AllDevicesWindow.cpp +8 -8
@@ 71,16 71,16 @@ namespace gui
        topBar->setActive(TopBar::Elements::SIM, false);

        leftArrowImage = new gui::Image(this,
                                        style::settings::window::allDevices::leftArrowImage::x,
                                        style::settings::window::allDevices::leftArrowImage::y,
                                        style::settings::window::allDevices::leftArrowImage::w,
                                        style::settings::window::allDevices::leftArrowImage::h,
                                        style::settings::window::leftArrowImage::x,
                                        style::settings::window::leftArrowImage::y,
                                        style::settings::window::leftArrowImage::w,
                                        style::settings::window::leftArrowImage::h,
                                        "arrow_left");
        crossImage     = new gui::Image(this,
                                    style::settings::window::allDevices::crossImage::x,
                                    style::settings::window::allDevices::crossImage::y,
                                    style::settings::window::allDevices::crossImage::w,
                                    style::settings::window::allDevices::crossImage::h,
                                    style::settings::window::crossImage::x,
                                    style::settings::window::crossImage::y,
                                    style::settings::window::crossImage::w,
                                    style::settings::window::crossImage::h,
                                    "cross");

        return optionsList;

A module-apps/application-settings-new/windows/AutolockWindow.cpp => module-apps/application-settings-new/windows/AutolockWindow.cpp +45 -0
@@ 0,0 1,45 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "AutolockWindow.hpp"
#include "application-settings-new/ApplicationSettings.hpp"
#include "windows/OptionSetting.hpp"

#include <i18/i18.hpp>

namespace gui
{

    AutolockWindow::AutolockWindow(app::Application *app) : BaseSettingsWindow(app, window::name::autolock)
    {
        setTitle(utils::localize.get("app_settings_display_locked_screen_autolock"));
    }

    auto AutolockWindow::buildOptionsList() -> std::list<gui::Option>
    {
        std::list<gui::Option> optionsList;
        std::vector<std::string> autoLockTimes = {"15s", "30s", "1m", "2m", "5m", "10m", "20m"};

        for (auto time : autoLockTimes) {
            optionsList.emplace_back(std::make_unique<gui::OptionSettings>(
                time,
                [=](gui::Item &item) {
                    selectedTime = time;
                    rebuildOptionList();
                    return true;
                },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::select),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                selectedTime == time ? RightItem::Checked : RightItem::Disabled));
        }

        return optionsList;
    }

} // namespace gui

A module-apps/application-settings-new/windows/AutolockWindow.hpp => module-apps/application-settings-new/windows/AutolockWindow.hpp +21 -0
@@ 0,0 1,21 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "BaseSettingsWindow.hpp"

namespace gui
{

    class AutolockWindow : public BaseSettingsWindow
    {
      public:
        AutolockWindow(app::Application *app);

      private:
        auto buildOptionsList() -> std::list<Option> override;

        std::string selectedTime;
    };
} // namespace gui

M module-apps/application-settings-new/windows/BaseSettingsWindow.cpp => module-apps/application-settings-new/windows/BaseSettingsWindow.cpp +14 -5
@@ 8,14 8,12 @@
namespace gui
{

    BaseSettingsWindow::BaseSettingsWindow(app::Application *app, std::string name) : AppWindow(app, name)
    {
        buildInterface();
    }
    BaseSettingsWindow::BaseSettingsWindow(app::Application *app, std::string name) : OptionWindow(app, name)
    {}

    void BaseSettingsWindow::buildInterface()
    {
        AppWindow::buildInterface();
        OptionWindow::buildInterface();

        bottomBar->setActive(BottomBar::Side::RIGHT, true);
        bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));


@@ 34,4 32,15 @@ namespace gui
        buildInterface();
    }

    void BaseSettingsWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        rebuildOptionList();
    }

    void BaseSettingsWindow::rebuildOptionList()
    {
        clearOptions();
        addOptions(buildOptionsList());
    }

} // namespace gui

M module-apps/application-settings-new/windows/BaseSettingsWindow.hpp => module-apps/application-settings-new/windows/BaseSettingsWindow.hpp +8 -4
@@ 3,14 3,14 @@

#pragma once

#include <AppWindow.hpp>
#include <Application.hpp>
#include <module-apps/windows/OptionWindow.hpp>
#include "Application.hpp"
#include "windows/AppWindow.hpp"
#include "windows/OptionWindow.hpp"

namespace gui
{

    class BaseSettingsWindow : public AppWindow
    class BaseSettingsWindow : public OptionWindow
    {
      public:
        BaseSettingsWindow(app::Application *app, std::string name);


@@ 19,7 19,11 @@ namespace gui
        void buildInterface() override;
        void destroyInterface() override;

        void rebuildOptionList();
        void onBeforeShow(ShowMode mode, SwitchData *data) override;

      protected:
        virtual void invalidate() noexcept {};
        virtual auto buildOptionsList() -> std::list<gui::Option> = 0;
    };
} // namespace gui

M module-apps/application-settings-new/windows/DisplayAndKeypadWindow.cpp => module-apps/application-settings-new/windows/DisplayAndKeypadWindow.cpp +32 -22
@@ 3,9 3,11 @@

#include "DisplayAndKeypadWindow.hpp"

#include <application-settings-new/ApplicationSettings.hpp>
#include "application-settings-new/ApplicationSettings.hpp"
#include "windows/OptionWindow.hpp"
#include "windows/OptionSetting.hpp"

#include <i18/i18.hpp>
#include <OptionWindow.hpp>

namespace gui
{


@@ 19,28 21,36 @@ namespace gui

    std::list<Option> DisplayAndKeypadWindow::displayAndKeypadOptionsList()
    {
        std::list<gui::Option> l;

        auto i18     = [](std::string text) { return utils::localize.get(text); };
        auto addMenu = [&](UTF8 name, std::string window = "") {
            l.emplace_back(gui::Option{name,
                                       [=](gui::Item &item) {
                                           if (window == "") {
                                               return false;
                                           }
                                           LOG_INFO("switching to %s page", window.c_str());
                                           application->switchWindow(window, nullptr);
                                           return true;
                                       },
                                       gui::Arrow::Enabled});
        std::list<gui::Option> optionList;

        auto addMenu = [&](UTF8 name, std::string window) {
            optionList.emplace_back(std::make_unique<gui::OptionSettings>(
                name,
                [=](gui::Item &item) {
                    if (window.empty()) {
                        return false;
                    }
                    LOG_INFO("switching to %s page", window.c_str());
                    application->switchWindow(window, nullptr);
                    return true;
                },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::select),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                RightItem::ArrowWhite));
        };

        addMenu(i18("app_settings_display_display_light"), gui::window::name::display_light);
        addMenu(i18("app_settings_display_font_size"), gui::window::name::font_size);
        addMenu(i18("app_settings_display_locked_screen"), gui::window::name::locked_screen);
        addMenu(i18("app_settings_display_keypad_light"), gui::window::name::keypad_light);
        addMenu(i18("app_settings_display_input_language"), gui::window::name::input_language);
        addMenu(utils::translateI18("app_settings_display_display_light"), gui::window::name::display_light);
        addMenu(utils::translateI18("app_settings_display_font_size"), gui::window::name::font_size);
        addMenu(utils::translateI18("app_settings_display_locked_screen"), gui::window::name::locked_screen);
        addMenu(utils::translateI18("app_settings_display_keypad_light"), gui::window::name::keypad_light);
        addMenu(utils::translateI18("app_settings_display_input_language"), gui::window::name::input_language);

        return l;
        return optionList;
    }
} // namespace gui

M module-apps/application-settings-new/windows/DisplayLightWindow.cpp => module-apps/application-settings-new/windows/DisplayLightWindow.cpp +46 -80
@@ 3,101 3,67 @@

#include "DisplayLightWindow.hpp"

#include <application-settings-new/ApplicationSettings.hpp>
#include "application-settings-new/ApplicationSettings.hpp"
#include "windows/OptionSetting.hpp"

#include <i18/i18.hpp>
#include <Common.hpp>
#include <InputEvent.hpp>

namespace gui
{
    DisplayLightWindow::DisplayLightWindow(app::Application *app) : BaseSettingsWindow(app, window::name::display_light)
    {
        buildInterface();
        setTitle(utils::localize.get("app_settings_display_display_light"));
    }

    void DisplayLightWindow::buildInterface()
    void DisplayLightWindow::switchHandler(bool &onOffSwitch)
    {
        BaseSettingsWindow::buildInterface();
        setTitle(utils::localize.get("app_settings_display_display_light"));

        int32_t offset_h = 8;

        body = new VBox(this,
                        0,
                        title->offset_h() + offset_h,
                        this->getWidth(),
                        this->getHeight() - offset_h - this->title->offset_h() - bottomBar->getHeight());
        body->setEdges(gui::RectangleEdge::None);

        displayLight = new Toggle(nullptr,
                                  0,
                                  0,
                                  body->getWidth(),
                                  style::window::label::big_h,
                                  utils::localize.get("app_settings_display_light_main"),
                                  false);

        autoLight = new Toggle(nullptr,
                               0,
                               0,
                               body->getWidth(),
                               style::window::label::big_h,
                               utils::localize.get("app_settings_display_light_auto"),
                               true);

        brightness = new UpDown(nullptr,
                                0,
                                0,
                                body->getWidth(),
                                style::window::label::big_h,
                                utils::localize.get("app_settings_display_light_brightness"),
                                default_brightness,
                                max_brightness);

        displayLight->activatedCallback = [this](Item &) {
            displayLightSwitchHandler();
            return true;
        };

        autoLight->activatedCallback = [this](Item &) {
            autoLightSwitchHandler();
            return true;
        };

        body->addWidget(displayLight);

        setFocusItem(body);

    } // namespace gui
        onOffSwitch = !onOffSwitch;
        rebuildOptionList();
    }

    void DisplayLightWindow::displayLightSwitchHandler()
    auto DisplayLightWindow::buildOptionsList() -> std::list<gui::Option>
    {
        body->removeWidget(autoLight);
        std::list<gui::Option> optionsList;

        auto addOnOffOoption = [&](UTF8 text, bool &toggle) {
            optionsList.emplace_back(std::make_unique<gui::OptionSettings>(
                text,
                [&](gui::Item &item) mutable {
                    switchHandler(toggle);
                    return true;
                },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::Switch),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                toggle ? RightItem::On : RightItem::Off));
        };

        if (displayLight->getState()) {
            body->addWidget(autoLight);
            setFocusItem(body);
            setFocusItem(autoLight);
        addOnOffOoption(utils::translateI18("app_settings_display_light_main"), isDisplayLightSwitchOn);
        if (isDisplayLightSwitchOn) {
            addOnOffOoption(utils::translateI18("app_settings_display_light_auto"), isAutoLightSwitchOn);
        }
    }

    void DisplayLightWindow::autoLightSwitchHandler()
    {
        body->removeWidget(brightness);
        if (!autoLight->getState()) {
            body->addWidget(brightness);
            setFocusItem(body);
            setFocusItem(brightness);
        if (isDisplayLightSwitchOn && !isAutoLightSwitchOn) {
            optionsList.emplace_back(std::make_unique<gui::OptionSettings>(
                utils::translateI18("app_settings_display_light_brightness"),
                [=](gui::Item &item) { return true; },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::set),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                RightItem::ArrowWhite));
        }
    }

    void DisplayLightWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {}

    void DisplayLightWindow::invalidate() noexcept
    {
        displayLight = nullptr;
        autoLight    = nullptr;
        brightness   = nullptr;
        return optionsList;
    }

} // namespace gui

M module-apps/application-settings-new/windows/DisplayLightWindow.hpp => module-apps/application-settings-new/windows/DisplayLightWindow.hpp +4 -22
@@ 3,14 3,7 @@

#pragma once

#include <module-apps/windows/OptionWindow.hpp>
#include "BaseSettingsWindow.hpp"
#include <i18/i18.hpp>
#include <ProgressBar.hpp>
#include <InputEvent.hpp>

#include "application-settings-new/widgets/UpDown.hpp"
#include "application-settings-new/widgets/Toggle.hpp"

namespace gui
{


@@ 19,23 12,12 @@ namespace gui
    {
      public:
        DisplayLightWindow(app::Application *app);
        void buildInterface() override;

      protected:
        void invalidate() noexcept override;

      private:
        void onBeforeShow(ShowMode mode, SwitchData *data) override;

        void displayLightSwitchHandler();
        void autoLightSwitchHandler();

        Toggle *displayLight = nullptr;
        Toggle *autoLight    = nullptr;
        UpDown *brightness   = nullptr;
        VBox *body           = nullptr;
        void switchHandler(bool &onOffSwitch);
        auto buildOptionsList() -> std::list<Option> override;

        const uint32_t max_brightness     = 5;
        const uint32_t default_brightness = 3;
        bool isDisplayLightSwitchOn = false;
        bool isAutoLightSwitchOn    = false;
    };
} // namespace gui

M module-apps/application-settings-new/windows/FontSizeWindow.cpp => module-apps/application-settings-new/windows/FontSizeWindow.cpp +5 -5
@@ 3,7 3,8 @@

#include "FontSizeWindow.hpp"

#include <application-settings-new/ApplicationSettings.hpp>
#include "application-settings-new/ApplicationSettings.hpp"

#include <i18/i18.hpp>

namespace gui


@@ 11,13 12,12 @@ namespace gui

    FontSizeWindow::FontSizeWindow(app::Application *app) : BaseSettingsWindow(app, gui::window::name::font_size)
    {
        buildInterface();
        setTitle(utils::localize.get("app_settings_display_font_size"));
    }

    void FontSizeWindow::buildInterface()
    auto FontSizeWindow::buildOptionsList() -> std::list<gui::Option>
    {
        BaseSettingsWindow::buildInterface();
        setTitle(utils::localize.get("app_settings_display_font_size"));
        return std::list<gui::Option>();
    }

} // namespace gui

M module-apps/application-settings-new/windows/FontSizeWindow.hpp => module-apps/application-settings-new/windows/FontSizeWindow.hpp +1 -1
@@ 12,6 12,6 @@ namespace gui
    {
      public:
        FontSizeWindow(app::Application *app);
        void buildInterface() override;
        auto buildOptionsList() -> std::list<gui::Option> override;
    };
} // namespace gui

M module-apps/application-settings-new/windows/InputLanguageWindow.cpp => module-apps/application-settings-new/windows/InputLanguageWindow.cpp +28 -6
@@ 3,21 3,43 @@

#include "InputLanguageWindow.hpp"

#include <application-settings-new/ApplicationSettings.hpp>
#include "application-settings-new/ApplicationSettings.hpp"
#include "windows/OptionSetting.hpp"

#include <i18/i18.hpp>

namespace gui
{

    InputLanguageWindow::InputLanguageWindow(app::Application *app)
        : BaseSettingsWindow(app, window::name::input_language)
    {
        buildInterface();
        setTitle(utils::localize.get("app_settings_display_input_language"));
    }

    void InputLanguageWindow::buildInterface()
    auto InputLanguageWindow::buildOptionsList() -> std::list<gui::Option>
    {
        BaseSettingsWindow::buildInterface();
        setTitle(utils::localize.get("app_settings_display_input_language"));
        std::list<gui::Option> optionsList;
        std::vector<std::string> availableLanguages = {"English", "Detush", "Polski", "Español", "Français"};

        for (auto lang : availableLanguages) {
            optionsList.emplace_back(std::make_unique<gui::OptionSettings>(
                lang,
                [=](gui::Item &item) {
                    selectedLang = lang;
                    rebuildOptionList();
                    return true;
                },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::select),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                selectedLang == lang ? RightItem::Checked : RightItem::Disabled));
        }

        return optionsList;
    }
} // namespace gui

M module-apps/application-settings-new/windows/InputLanguageWindow.hpp => module-apps/application-settings-new/windows/InputLanguageWindow.hpp +6 -1
@@ 12,6 12,11 @@ namespace gui
    {
      public:
        InputLanguageWindow(app::Application *app);
        void buildInterface() override;

      protected:
        auto buildOptionsList() -> std::list<gui::Option> override;

      private:
        std::string selectedLang;
    };
} // namespace gui

M module-apps/application-settings-new/windows/KeypadLightWindow.cpp => module-apps/application-settings-new/windows/KeypadLightWindow.cpp +36 -31
@@ 3,51 3,56 @@

#include "KeypadLightWindow.hpp"

#include "CheckBoxWithLabel.hpp"
#include "application-settings-new/ApplicationSettings.hpp"
#include "windows/OptionSetting.hpp"

#include <application-settings-new/ApplicationSettings.hpp>
#include <i18/i18.hpp>
#include <BoxLayout.hpp>

namespace gui
{

    KeypadLightWindow::KeypadLightWindow(app::Application *app) : BaseSettingsWindow(app, window::name::keypad_light)
    {
        buildInterface();
        setTitle(utils::localize.get("app_settings_display_keypad_light"));
    }

    void KeypadLightWindow::buildInterface()
    void KeypadLightWindow::switchHandler(bool &toggleSwitch)
    {
        BaseSettingsWindow::buildInterface();
        setTitle(utils::localize.get("app_settings_display_keypad_light"));
        isActiveSwitchOn   = false;
        isOffSwitchOn      = false;
        isAlwaysOnSwitchOn = false;

        toggleSwitch = !toggleSwitch;
        rebuildOptionList();
    }

        auto body =
            new VBox(nullptr,
                     0,
                     title->offset_h() + style::margins::big,
                     this->getWidth(),
                     this->getHeight() - style::margins::big - this->title->offset_h() - bottomBar->getHeight());
        body->setEdges(gui::RectangleEdge::None);

        auto toggleBoxes = [this](CheckBoxWithLabel &active) {
            for (CheckBoxWithLabel *box : boxes) {
                box->setChecked(false);
                if (&active == box) {
                    box->setChecked(!box->isChecked());
                }
            }
    auto KeypadLightWindow::buildOptionsList() -> std::list<gui::Option>
    {
        std::list<gui::Option> optionsList;

        auto addCheckOption = [&](UTF8 text, bool &Switch) {
            optionsList.emplace_back(std::make_unique<gui::OptionSettings>(
                text,
                [&](gui::Item &item) mutable {
                    switchHandler(Switch);
                    return true;
                },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::Switch),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                Switch ? RightItem::Checked : RightItem::Disabled));
        };

        boxes.push_back(new CheckBoxWithLabel(
            body, 0, 0, utils::localize.get("app_settings_display_keypad_light_on"), toggleBoxes));
        boxes.push_back(new CheckBoxWithLabel(
            body, 0, 0, utils::localize.get("app_settings_display_keypad_light_active"), toggleBoxes));
        boxes.push_back(new CheckBoxWithLabel(
            body, 0, 0, utils::localize.get("app_settings_display_keypad_light_off"), toggleBoxes));
        addCheckOption(utils::translateI18("app_settings_display_keypad_light_on"), isAlwaysOnSwitchOn);
        addCheckOption(utils::translateI18("app_settings_display_keypad_light_off"), isOffSwitchOn);
        addCheckOption(utils::translateI18("app_settings_display_keypad_light_active"), isActiveSwitchOn);

        addWidget(body);
        setFocusItem(body);
    }
        return optionsList;
    } // namespace gui

} // namespace gui

M module-apps/application-settings-new/windows/KeypadLightWindow.hpp => module-apps/application-settings-new/windows/KeypadLightWindow.hpp +6 -4
@@ 7,15 7,17 @@

namespace gui
{
    class CheckBoxWithLabel;

    class KeypadLightWindow : public BaseSettingsWindow
    {
      public:
        KeypadLightWindow(app::Application *app);
        void buildInterface() override;

      private:
        std::vector<CheckBoxWithLabel *> boxes;
        void switchHandler(bool &onOffSwitch);
        std::list<Option> buildOptionsList() override;

        bool isAlwaysOnSwitchOn = false;
        bool isActiveSwitchOn   = false;
        bool isOffSwitchOn      = false;
    };
} // namespace gui

M module-apps/application-settings-new/windows/LockedScreenWindow.cpp => module-apps/application-settings-new/windows/LockedScreenWindow.cpp +34 -6
@@ 2,21 2,49 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "LockedScreenWindow.hpp"

#include "application-settings-new/ApplicationSettings.hpp"
#include "i18/i18.hpp"
#include "windows/OptionSetting.hpp"

#include <i18/i18.hpp>

namespace gui
{

    LockedScreenWindow::LockedScreenWindow(app::Application *app) : BaseSettingsWindow(app, window::name::locked_screen)
    {
        buildInterface();
        setTitle(utils::localize.get("app_settings_display_locked_screen"));
    }

    void LockedScreenWindow::buildInterface()
    auto LockedScreenWindow::buildOptionsList() -> std::list<Option>
    {
        BaseSettingsWindow::buildInterface();
        setTitle(utils::localize.get("app_settings_display_locked_screen"));
        std::list<gui::Option> optionList;

        auto addMenu = [&](UTF8 name, std::string window = "") {
            optionList.emplace_back(std::make_unique<gui::OptionSettings>(
                name,
                [=](gui::Item &item) {
                    if (window.empty()) {
                        return false;
                    }
                    LOG_INFO("switching to %s page", window.c_str());
                    application->switchWindow(window, nullptr);
                    return true;
                },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::select),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                gui::RightItem::ArrowWhite));
        };

        addMenu(utils::translateI18("app_settings_display_locked_screen_autolock"), gui::window::name::autolock);
        addMenu(utils::translateI18("app_settings_display_locked_screen_wallpaper"), gui::window::name::wallpaper);

        return optionList;
    }

} // namespace gui

M module-apps/application-settings-new/windows/LockedScreenWindow.hpp => module-apps/application-settings-new/windows/LockedScreenWindow.hpp +1 -1
@@ 11,6 11,6 @@ namespace gui
    {
      public:
        LockedScreenWindow(app::Application *app);
        void buildInterface() override;
        auto buildOptionsList() -> std::list<Option> override;
    };
} // namespace gui

A module-apps/application-settings-new/windows/QuotesAddWindow.cpp => module-apps/application-settings-new/windows/QuotesAddWindow.cpp +33 -0
@@ 0,0 1,33 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "QuotesAddWindow.hpp"

#include "application-settings-new/ApplicationSettings.hpp"

#include <i18/i18.hpp>
#include <widgets/Text.hpp>

namespace gui
{
    QuotesAddWindow::QuotesAddWindow(app::Application *app) : AppWindow(app, gui::window::name::quotes)
    {
        setTitle(utils::localize.get("app_settings_display_locked_screen_new_quote"));
    }

    void QuotesAddWindow::buildInterface()
    {
        bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::save));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));

        auto text = new gui::Text(nullptr,
                                  style::window::default_left_margin,
                                  title->offset_h() + style::margins::big,
                                  style::window::default_body_width,
                                  style::window::default_body_height);

        addWidget(text);
        setFocusItem(text);
    }

} // namespace gui

A module-apps/application-settings-new/windows/QuotesAddWindow.hpp => module-apps/application-settings-new/windows/QuotesAddWindow.hpp +21 -0
@@ 0,0 1,21 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "BaseSettingsWindow.hpp"

namespace gui
{
    class CheckBoxWithLabel;

    class QuotesAddWindow : public AppWindow
    {
      public:
        QuotesAddWindow(app::Application *app);
        void buildInterface() override;

      private:
        std::vector<CheckBoxWithLabel *> boxes;
    };
} // namespace gui

A module-apps/application-settings-new/windows/QuotesMainWindow.cpp => module-apps/application-settings-new/windows/QuotesMainWindow.cpp +93 -0
@@ 0,0 1,93 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "QuotesMainWindow.hpp"

#include "application-settings-new/ApplicationSettings.hpp"
#include "application-settings-new/widgets/SettingsStyle.hpp"
#include "windows/OptionSetting.hpp"

#include <InputEvent.hpp>
#include <i18/i18.hpp>
#include <json/json11.hpp>
#include <vfs.hpp>

namespace gui
{
    namespace quotes
    {
        inline static std::string path = "sys/data/applications/settings/quotes.json";
    } // namespace quotes

    QuotesMainWindow::QuotesMainWindow(app::Application *app) : BaseSettingsWindow(app, gui::window::name::quotes)
    {
        setTitle(utils::localize.get("app_settings_display_locked_screen_quotes"));
        readQuotes(quotes::path);
    }

    auto QuotesMainWindow::onInput(const InputEvent &inputEvent) -> bool
    {
        // check if any of the lower inheritance onInput methods catch the event
        if (AppWindow::onInput(inputEvent)) {
            return true;
        }
        if (inputEvent.state == InputEvent::State::keyReleasedShort) {
            switch (inputEvent.keyCode) {
            case gui::KeyCode::KEY_LEFT:
                application->switchWindow(gui::window::name::new_quote, nullptr);
                return true;
            default:
                break;
            }
        }
        return false;
    }

    void QuotesMainWindow::readQuotes(fs::path fn)
    {
        std::string err;

        std::string fileContents = vfs.loadFileAsString(fn);

        auto obj = json11::Json::parse(fileContents, err).array_items();

        if (!err.empty()) {
            LOG_ERROR("Error while parsing quotes: %s", err.c_str());
        }

        std::transform(obj.begin(), obj.end(), std::back_inserter(quotes), [](auto item) {
            return std::pair{item["quote"].string_value(), false};
        });
    }

    auto QuotesMainWindow::buildOptionsList() -> std::list<gui::Option>
    {
        std::list<gui::Option> optionsList;

        for (auto &quote : quotes) {
            optionsList.emplace_back(std::make_unique<gui::OptionSettings>(
                utils::translateI18(quote.first),
                [&quote, this](gui::Item &item) {
                    switchHandler(quote.second);
                    return true;
                },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::Switch),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                quote.second ? RightItem::Checked : RightItem::Disabled));
        }

        return optionsList;
    }

    void QuotesMainWindow::switchHandler(bool &optionSwitch)
    {
        optionSwitch = !optionSwitch;
        rebuildOptionList();
    }
} // namespace gui

A module-apps/application-settings-new/windows/QuotesMainWindow.hpp => module-apps/application-settings-new/windows/QuotesMainWindow.hpp +28 -0
@@ 0,0 1,28 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "BaseSettingsWindow.hpp"

namespace gui
{
    class CheckBoxWithLabel;

    class QuotesMainWindow : public BaseSettingsWindow
    {
      public:
        QuotesMainWindow(app::Application *app);

        auto onInput(const InputEvent &inputEvent) -> bool override;

      protected:
        auto buildOptionsList() -> std::list<Option> override;

      private:
        void readQuotes(fs::path fn);
        void switchHandler(bool &optionSwitch);

        std::list<std::pair<std::string, bool>> quotes;
    };
} // namespace gui

A module-apps/application-settings-new/windows/WallpaperWindow.cpp => module-apps/application-settings-new/windows/WallpaperWindow.cpp +75 -0
@@ 0,0 1,75 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "WallpaperWindow.hpp"

#include "application-settings-new/ApplicationSettings.hpp"
#include "windows/OptionSetting.hpp"

#include <i18/i18.hpp>

namespace gui
{
    WallpaperWindow::WallpaperWindow(app::Application *app) : BaseSettingsWindow(app, window::name::wallpaper)
    {
        setTitle(utils::localize.get("app_settings_display_locked_screen_wallpaper"));
    }

    auto WallpaperWindow::buildOptionsList() -> std::list<gui::Option>
    {
        std::list<gui::Option> optionsList;

        auto addCheckOption = [&](UTF8 text, bool &Switch) {
            optionsList.emplace_back(std::make_unique<gui::OptionSettings>(
                text,
                [&](gui::Item &item) mutable {
                    switchHandler(Switch);
                    return true;
                },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::Switch),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                Switch ? RightItem::Checked : RightItem::Disabled));
        };

        addCheckOption(utils::translateI18("app_settings_display_wallpaper_logo"), isWallpaperLogoSwitchOn);
        addCheckOption(utils::translateI18("app_settings_display_wallpaper_clock"), isWallpaperClockSwitchOn);
        addCheckOption(utils::translateI18("app_settings_display_wallpaper_quotes"), isWallpaperQuotesSwitchOn);

        if (isWallpaperQuotesSwitchOn) {
            optionsList.emplace_back(std::make_unique<gui::OptionSettings>(
                utils::translateI18("app_settings_display_wallpaper_select_quotes"),
                [=](gui::Item &item) {
                    application->switchWindow(gui::window::name::quotes, nullptr);
                    return true;
                },
                [=](gui::Item &item) {
                    if (item.focus) {
                        this->setBottomBarText(utils::translateI18(style::strings::common::select),
                                               BottomBar::Side::CENTER);
                    }
                    return true;
                },
                this,
                RightItem::ArrowWhite));
        }

        return optionsList;
    }

    void WallpaperWindow::switchHandler(bool &optionSwitch)
    {
        isWallpaperQuotesSwitchOn = false;
        isWallpaperClockSwitchOn  = false;
        isWallpaperLogoSwitchOn   = false;

        optionSwitch = !optionSwitch;
        rebuildOptionList();
    }

} // namespace gui

A module-apps/application-settings-new/windows/WallpaperWindow.hpp => module-apps/application-settings-new/windows/WallpaperWindow.hpp +27 -0
@@ 0,0 1,27 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "BaseSettingsWindow.hpp"

namespace gui
{
    class CheckBoxWithLabel;

    class WallpaperWindow : public BaseSettingsWindow
    {
      public:
        WallpaperWindow(app::Application *app);

      private:
        void switchHandler(bool &onOffSwitch);
        auto buildOptionsList() -> std::list<Option> override;

        bool isWallpaperLogoSwitchOn   = false;
        bool isWallpaperClockSwitchOn  = false;
        bool isWallpaperQuotesSwitchOn = false;

        Item *quotes;
    };
} // namespace gui

M module-apps/windows/OptionSetting.cpp => module-apps/windows/OptionSetting.cpp +11 -5
@@ 15,13 15,13 @@ namespace gui
        style::window::decorate(optionBodyHBox);

        auto optionNameLabel = new Label(optionBodyHBox, 0, 0, 0, 0, text);
        optionNameLabel->setMinimumSize(style::window::default_body_width - style::buttonOnOff::w,
                                        style::window::label::big_h);
        optionNameLabel->setEdges(RectangleEdge::None);
        optionNameLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
        optionNameLabel->setFont(style::window::font::big);

        std::string imageName;
        int optionRightItemWidth = 0;

        switch (rightItem) {
        case RightItem::ArrowBlack:
            imageName = "right_label_arrow";


@@ 31,23 31,29 @@ namespace gui
            break;
        case RightItem::On:
            new ButtonOnOff(optionBodyHBox, ButtonState::On);
            optionRightItemWidth = style::buttonOnOff::w;
            break;
        case RightItem::Off:
            new ButtonOnOff(optionBodyHBox, ButtonState::Off);
            optionRightItemWidth = style::buttonOnOff::w;
            break;
        case RightItem::Bt:
            imageName = "bt";
            break;
        case RightItem::Checked:
            imageName = "small_tick_W_M";
            break;
        default:
            break;
        }

        if (!imageName.empty()) {
            auto image = new gui::Image(optionBodyHBox, 0, 0, 0, 0, imageName);
            optionNameLabel->setMinimumSize(style::window::default_body_width - image->getWidth(),
                                            style::window::label::big_h);
            auto image           = new gui::Image(optionBodyHBox, 0, 0, 0, 0, imageName);
            optionRightItemWidth = image->getWidth();
        }

        optionNameLabel->setMinimumSize(style::window::default_body_width - optionRightItemWidth,
                                        style::window::label::big_h);
        return optionBodyHBox;
    }
} // namespace gui

M module-apps/windows/OptionSetting.hpp => module-apps/windows/OptionSetting.hpp +2 -1
@@ 15,7 15,8 @@ namespace gui
        ArrowWhite,
        On,
        Off,
        Bt
        Bt,
        Checked,
    };

    class OptionSettings : public option::Base

M module-gui/gui/widgets/CheckBoxWithLabel.cpp => module-gui/gui/widgets/CheckBoxWithLabel.cpp +3 -2
@@ 17,7 17,8 @@ namespace gui
                                  style::checkbox::check_x,
                                  style::checkbox::check_y,
                                  style::checkbox::check_width,
                                  style::window::label::big_h);
                                  style::window::label::small_h);
        check->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));

        label->activatedCallback = [=](Item &item) {
            setChecked(!check->isChecked());


@@ 35,7 36,7 @@ namespace gui
         */
        parent->addWidget(body);
        body->addWidget(label);
        label->addWidget(check);
        body->addWidget(check);
    }

    bool CheckBoxWithLabel::isChecked() const

M module-gui/gui/widgets/CheckBoxWithLabel.hpp => module-gui/gui/widgets/CheckBoxWithLabel.hpp +4 -4
@@ 7,10 7,10 @@

namespace style::checkbox
{
    const inline int check_x           = 380;
    const inline int check_y           = 12;
    const inline int description_width = 340;
    const inline int check_width       = 60;
    const inline int check_x           = 400;
    const inline int check_y           = 25;
    const inline int description_width = 380;
    const inline int check_width       = 40;
} // namespace style::checkbox

namespace gui