~aleteoryx/muditaos

4147866c712bcc4b703cb9e69a06c4a72a1d2d00 — Przemyslaw Brudny 4 years ago 3ac4bd4
[EGD-7211] Sim contacts import selector UI part

Added sim contacts import selector UI part.
Fixed BoxLayout focusChangedCallback. Fixed
SetFont redraw. Refactored Check and
CheckWithLabel widgets.
M module-apps/application-alarm-clock/widgets/CustomCheckBoxWithLabel.cpp => module-apps/application-alarm-clock/widgets/CustomCheckBoxWithLabel.cpp +1 -1
@@ 91,7 91,7 @@ namespace gui
    {
        for (auto const &[key, dayName] : weekDays) {
            if (descriptionLabel->getText() == utils::translate(dayName)) {
                checkBox->setImageVisible(checkBoxData.getData(static_cast<uint32_t>(key)));
                checkBox->setCheck(checkBoxData.getData(static_cast<uint32_t>(key)));
            }
        }
    }

M module-apps/application-phonebook/widgets/InputLinesWithLabelIWidget.cpp => module-apps/application-phonebook/widgets/InputLinesWithLabelIWidget.cpp +0 -4
@@ 60,15 60,11 @@ namespace gui
        focusChangedCallback = [&](Item &item) {
            setFocusItem(focus ? vBox : nullptr);

            auto tempText = inputText->getText();

            if (focus) {
                inputText->setFont(style::window::font::mediumbold);
                inputText->setText(tempText);
            }
            else {
                inputText->setFont(style::window::font::medium);
                inputText->setText(tempText);
            }
            return true;
        };

M module-apps/application-settings/ApplicationSettings.cpp => module-apps/application-settings/ApplicationSettings.cpp +7 -0
@@ 17,6 17,7 @@
#include <application-settings/windows/network/NetworkWindow.hpp>
#include <application-settings/windows/network/SimPINSettingsWindow.hpp>
#include <application-settings/windows/network/SimCardsWindow.hpp>
#include <application-settings/windows/network/SimContactsImportWindow.hpp>
#include <application-settings/windows/network/NewApnWindow.hpp>
#include <application-settings/windows/network/ApnSettingsWindow.hpp>
#include <application-settings/windows/network/ApnOptionsWindow.hpp>


@@ 379,6 380,12 @@ namespace app
        windowsFactory.attach(gui::window::name::sim_pin_settings, [](Application *app, const std::string &name) {
            return std::make_unique<gui::SimPINSettingsWindow>(app);
        });
        windowsFactory.attach(gui::window::name::import_contacts, [&](Application *app, const std::string &name) {
            auto model     = std::make_unique<SimContactsImportModel>(this);
            auto presenter = std::make_unique<SimContactsImportWindowPresenter>(std::move(model));
            return std::make_unique<gui::SimContactsImportWindow>(app, std::move(presenter));
        });

        windowsFactory.attach(gui::window::name::new_apn, [](Application *app, const std::string &name) {
            return std::make_unique<gui::NewApnWindow>(app);
        });

M module-apps/application-settings/CMakeLists.txt => module-apps/application-settings/CMakeLists.txt +4 -0
@@ 19,6 19,7 @@ target_sources( ${PROJECT_NAME}
        models/bluetooth/BluetoothSettingsModel.cpp
        models/network/ApnSettingsModel.cpp
        models/network/NewApnModel.cpp
        models/network/SimContactsImportModel.cpp
        models/display-keypad/QuotesModel.cpp
        models/display-keypad/CategoriesModel.cpp
        models/apps/AudioSettingsModel.cpp


@@ 27,12 28,14 @@ target_sources( ${PROJECT_NAME}
        models/system/SARInfoRepository.cpp
        models/system/FactoryData.cpp
        models/system/TechnicalInformationModel.cpp
        presenter/network/SimContactsImportWindowPresenter.cpp
        presenter/system/SARInfoWindowPresenter.cpp
        presenter/system/TechnicalWindowPresenter.cpp
        widgets/SpinBoxOptionSettings.cpp
        widgets/advanced/ColorTestListItem.cpp
        widgets/advanced/ColorTestListView.cpp
        widgets/network/ApnInputWidget.cpp
        widgets/network/SimContactImportSelectWidget.cpp
        widgets/display-keypad/QuoteWidget.cpp
        widgets/display-keypad/CategoryWidget.cpp
        widgets/apps/SettingsSoundItem.cpp


@@ 55,6 58,7 @@ target_sources( ${PROJECT_NAME}
        windows/network/NetworkWindow.cpp
        windows/network/SimCardsWindow.cpp
        windows/network/SimPINSettingsWindow.cpp
        windows/network/SimContactsImportWindow.cpp
        windows/network/ApnSettingsWindow.cpp
        windows/network/ApnOptionsWindow.cpp
        windows/network/NewApnWindow.cpp

A module-apps/application-settings/models/network/SimContactsImportModel.cpp => module-apps/application-settings/models/network/SimContactsImportModel.cpp +47 -0
@@ 0,0 1,47 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SimContactsImportModel.hpp"

#include <application-settings/widgets/network/SimContactImportSelectWidget.hpp>
#include <ListView.hpp>
#include <i18n/i18n.hpp>

SimContactsImportModel::SimContactsImportModel(app::Application *app) : application(app)
{
    createData();
}

auto SimContactsImportModel::requestRecordsCount() -> unsigned int
{
    return internalData.size();
}

auto SimContactsImportModel::getMinimalItemSpaceRequired() const -> unsigned int
{
    return style::window::label::big_h + style::margins::big;
}

void SimContactsImportModel::requestRecords(const uint32_t offset, const uint32_t limit)
{
    setupModel(offset, limit);
    list->onProviderDataUpdate();
}

auto SimContactsImportModel::getItem(gui::Order order) -> gui::ListItem *
{
    return getRecord(order);
}

void SimContactsImportModel::createData()
{
    for (auto item : internalData) {
        item->deleteByList = false;
    }
}

void SimContactsImportModel::clearData()
{
    list->reset();
    eraseInternalData();
}

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

#pragma once

#include <InternalModel.hpp>
#include <ListItemProvider.hpp>
#include <ContactRecord.hpp>
#include <Application.hpp>

class SimContactsImportModel : public app::InternalModel<gui::ListItem *>, public gui::ListItemProvider
{
  private:
    app::Application *application = nullptr;
    std::vector<ContactRecord> importedRecords;

  public:
    explicit SimContactsImportModel(app::Application *app);

    void createData();
    void clearData();

    [[nodiscard]] auto requestRecordsCount() -> unsigned int override;
    [[nodiscard]] auto getMinimalItemSpaceRequired() const -> unsigned int override;
    auto getItem(gui::Order order) -> gui::ListItem * override;
    void requestRecords(const uint32_t offset, const uint32_t limit) override;
};

A module-apps/application-settings/presenter/network/SimContactsImportWindowPresenter.cpp => module-apps/application-settings/presenter/network/SimContactsImportWindowPresenter.cpp +19 -0
@@ 0,0 1,19 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SimContactsImportWindowPresenter.hpp"

SimContactsImportWindowPresenter::SimContactsImportWindowPresenter(
    std::shared_ptr<SimContactsImportModel> simContactsProvider)
    : simContactsProvider{std::move(simContactsProvider)}
{}

std::shared_ptr<gui::ListItemProvider> SimContactsImportWindowPresenter::getSimContactsProvider() const
{
    return simContactsProvider;
}

void SimContactsImportWindowPresenter::clearProviderData() const
{
    simContactsProvider->clearData();
}

A module-apps/application-settings/presenter/network/SimContactsImportWindowPresenter.hpp => module-apps/application-settings/presenter/network/SimContactsImportWindowPresenter.hpp +37 -0
@@ 0,0 1,37 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <BasePresenter.hpp>
#include <application-settings/models/network/SimContactsImportModel.hpp>

class SimContactsImportWindowContract
{
  public:
    class View
    {
      public:
        virtual ~View() noexcept = default;
    };
    class Presenter : public app::BasePresenter<SimContactsImportWindowContract::View>
    {
      public:
        virtual ~Presenter() noexcept = default;

        virtual std::shared_ptr<gui::ListItemProvider> getSimContactsProvider() const = 0;
        virtual void clearProviderData() const                                        = 0;
    };
};

class SimContactsImportWindowPresenter : public SimContactsImportWindowContract::Presenter
{
  public:
    explicit SimContactsImportWindowPresenter(std::shared_ptr<SimContactsImportModel> simContactsProvider);

    std::shared_ptr<gui::ListItemProvider> getSimContactsProvider() const override;
    void clearProviderData() const override;

  private:
    std::shared_ptr<SimContactsImportModel> simContactsProvider;
};

M module-apps/application-settings/widgets/network/ApnInputWidget.cpp => module-apps/application-settings/widgets/network/ApnInputWidget.cpp +0 -4
@@ 57,15 57,11 @@ namespace gui
        focusChangedCallback = [&](Item &item) {
            setFocusItem(focus ? vBox : nullptr);

            auto tempText = inputText->getText();

            if (focus) {
                inputText->setFont(style::window::font::mediumbold);
                inputText->setText(tempText);
            }
            else {
                inputText->setFont(style::window::font::medium);
                inputText->setText(tempText);
            }
            return true;
        };

A module-apps/application-settings/widgets/network/SimContactImportSelectWidget.cpp => module-apps/application-settings/widgets/network/SimContactImportSelectWidget.cpp +41 -0
@@ 0,0 1,41 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SimContactImportSelectWidget.hpp"

namespace gui
{
    SimContactImportSelectWidget::SimContactImportSelectWidget(
        std::string contactName,
        const std::function<void(const UTF8 &text)> &bottomBarTemporaryMode,
        const std::function<void()> &bottomBarRestoreFromTemporaryMode)
    {
        setEdges(RectangleEdge::None);
        setMinimumSize(style::window::default_body_width, style::window::label::big_h);
        setMargins(gui::Margins(style::widgets::leftMargin, style::margins::big, 0, 0));

        checkBoxWithLabel = new gui::CheckBoxWithLabel(this,
                                                       0,
                                                       0,
                                                       0,
                                                       0,
                                                       contactName,
                                                       bottomBarTemporaryMode,
                                                       bottomBarRestoreFromTemporaryMode,
                                                       BottomBar::Side::LEFT);

        inputCallback = [&]([[maybe_unused]] Item &item, const InputEvent &event) {
            return checkBoxWithLabel->onInput(event);
        };

        focusChangedCallback = [&](Item &item) {
            setFocusItem(focus ? checkBoxWithLabel : nullptr);
            return true;
        };

        dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
            checkBoxWithLabel->setArea({0, 0, newDim.w, newDim.h});
            return true;
        };
    }
} /* namespace gui */

A module-apps/application-settings/widgets/network/SimContactImportSelectWidget.hpp => module-apps/application-settings/widgets/network/SimContactImportSelectWidget.hpp +22 -0
@@ 0,0 1,22 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <ListItem.hpp>
#include <CheckBoxWithLabel.hpp>

namespace gui
{
    class SimContactImportSelectWidget : public ListItem
    {
      private:
        gui::CheckBoxWithLabel *checkBoxWithLabel = nullptr;

      public:
        SimContactImportSelectWidget(std::string contactName,
                                     const std::function<void(const UTF8 &text)> &bottomBarTemporaryMode = nullptr,
                                     const std::function<void()> &bottomBarRestoreFromTemporaryMode      = nullptr);
    };

} /* namespace gui */

M module-apps/application-settings/windows/network/SimCardsWindow.cpp => module-apps/application-settings/windows/network/SimCardsWindow.cpp +2 -3
@@ 82,7 82,6 @@ namespace gui
            gui::option::SettingRightItem::ArrowWhite,
            false));

#if DISABLED_SETTINGS_OPTIONS == 1
        optList.emplace_back(std::make_unique<gui::option::OptionSettings>(
            utils::translate("app_settings_network_import_contacts_from_sim_card"),
            [=](gui::Item &item) {


@@ 90,8 89,8 @@ namespace gui
                return true;
            },
            nullptr,
            nullptr));
#endif // DISABLED_SETTINGS_OPTIONS
            nullptr,
            gui::option::SettingRightItem::ArrowWhite));

        bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::select));


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

#include "SimContactsImportWindow.hpp"

#include <application-settings/windows/WindowNames.hpp>

namespace gui
{
    SimContactsImportWindow::SimContactsImportWindow(
        app::Application *app, std::unique_ptr<SimContactsImportWindowContract::Presenter> simImportPresenter)
        : AppWindow(app, gui::window::name::import_contacts), presenter(std::move(simImportPresenter))
    {
        presenter->attach(this);
        buildInterface();
    }

    void SimContactsImportWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        list->rebuildList();
    }

    void SimContactsImportWindow::onClose(CloseReason reason)
    {
        if (reason != CloseReason::PhoneLock) {
            presenter->clearProviderData();
        }
    }

    void SimContactsImportWindow::buildInterface()
    {
        AppWindow::buildInterface();

        setTitle(utils::translate("app_settings_network_import_contacts_from_sim_card"));

        bottomBar->setActive(gui::BottomBar::Side::RIGHT, true);
        bottomBar->setText(gui::BottomBar::Side::RIGHT, utils::translate(::style::strings::common::back));

        list = new ListView(this,
                            style::window::default_left_margin,
                            style::window::default_vertical_pos,
                            style::listview::body_width_with_scroll,
                            style::window::default_body_height,
                            presenter->getSimContactsProvider(),
                            listview::ScrollBarType::Fixed);

        setFocusItem(list);
    }
} // namespace gui

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

#pragma once

#include <application-settings/windows/BaseSettingsWindow.hpp>
#include <application-settings/presenter/network/SimContactsImportWindowPresenter.hpp>
#include <application-settings/models/network/SimContactsImportModel.hpp>

namespace gui
{
    class SimContactsImportWindow : public AppWindow, public SimContactsImportWindowContract::View
    {

      public:
        SimContactsImportWindow(app::Application *app,
                                std::unique_ptr<SimContactsImportWindowContract::Presenter> presenter);

      private:
        ListView *list = nullptr;

        void buildInterface() override;
        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        void onClose(CloseReason reason) override;

        std::shared_ptr<SimContactsImportWindowPresenter::Presenter> presenter;
    };

} // namespace gui

M module-gui/gui/widgets/BoxLayout.cpp => module-gui/gui/widgets/BoxLayout.cpp +1 -1
@@ 46,7 46,7 @@ namespace gui
        else
            this->setFocusItem(nullptr);
        this->setNavigation();
        if (this->focusChangedCallback) {
        if (this->focusChangedCallback && state != focus) {
            this->focusChangedCallback(*this);
        }
        return true;

M module-gui/gui/widgets/CheckBox.cpp => module-gui/gui/widgets/CheckBox.cpp +27 -30
@@ 2,8 2,8 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "CheckBox.hpp"
#include "InputEvent.hpp"
#include "Style.hpp"
#include <InputEvent.hpp>
#include <i18n/i18n.hpp>

namespace gui


@@ 14,19 14,18 @@ namespace gui
                       const uint32_t &y,
                       const uint32_t &w,
                       const uint32_t &h,
                       std::function<void(const UTF8 &text)> bottomBarTemporaryMode,
                       std::function<void()> bottomBarRestoreFromTemporaryMode,
                       bool textOnLeft)
                       const std::function<void(const UTF8 &text)> &bottomBarTemporaryMode,
                       const std::function<void()> &bottomBarRestoreFromTemporaryMode,
                       BottomBar::Side bottomBarSide)
        : HBox(parent, x, y, w, h), bottomBarTemporaryMode(bottomBarTemporaryMode),
          bottomBarRestoreFromTemporaryMode(bottomBarRestoreFromTemporaryMode), textOnLeft(textOnLeft)
          bottomBarRestoreFromTemporaryMode(bottomBarRestoreFromTemporaryMode), bottomBarSide(bottomBarSide)

    {
        setEdges(RectangleEdge::Bottom);
        setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));

        image = new Image("small_tick_W_M");
        image = new Image(this, "small_tick_W_M");
        image->setVisible(false);
        addWidget(image);

        applyCallbacks();
    }


@@ 35,17 34,22 @@ namespace gui
    {
        focusChangedCallback = [&](Item &item) {
            if (focus) {
                setFocusItem(image);
                if (image->visible) {
                    bottomBarTemporaryMode(utils::translate("common_uncheck"));
                if (isChecked()) {
                    if (bottomBarTemporaryMode) {
                        bottomBarTemporaryMode(utils::translate("common_uncheck"));
                    }
                }
                else {
                    bottomBarTemporaryMode(utils::translate("common_check"));
                    if (bottomBarTemporaryMode) {
                        bottomBarTemporaryMode(utils::translate("common_check"));
                    }
                }
            }
            else {
                setFocusItem(nullptr);
                bottomBarRestoreFromTemporaryMode();
                if (bottomBarRestoreFromTemporaryMode) {
                    bottomBarRestoreFromTemporaryMode();
                }
            }
            return true;
        };


@@ 54,37 58,30 @@ namespace gui
            if (!event.isShortRelease()) {
                return false;
            }
            if (textOnLeft) {
                if (event.is(gui::KeyCode::KEY_LF)) {
                    image->setVisible(!image->visible);
                    if (image->visible) {
            if ((bottomBarSide == BottomBar::Side::LEFT && event.is(gui::KeyCode::KEY_LF)) ||
                (bottomBarSide == BottomBar::Side::CENTER && event.is(gui::KeyCode::KEY_ENTER))) {
                setCheck(!isChecked());
                if (isChecked()) {
                    if (bottomBarTemporaryMode) {
                        bottomBarTemporaryMode(utils::translate("common_uncheck"));
                    }
                    else {
                        bottomBarTemporaryMode(utils::translate("common_check"));
                    }
                    return true;
                }
            }
            else {
                if (event.is(gui::KeyCode::KEY_ENTER)) {
                    image->setVisible(!image->visible);
                    if (image->visible) {
                        bottomBarTemporaryMode(utils::translate("common_uncheck"));
                    }
                    else {
                else {
                    if (bottomBarTemporaryMode) {
                        bottomBarTemporaryMode(utils::translate("common_check"));
                    }
                    return true;
                }
                return true;
            }

            return false;
        };
    }

    void CheckBox::setImageVisible(bool state)
    void CheckBox::setCheck(bool state)
    {
        image->setVisible(state);
        resizeItems();
    }

    bool CheckBox::isChecked()

M module-gui/gui/widgets/CheckBox.hpp => module-gui/gui/widgets/CheckBox.hpp +8 -7
@@ 1,10 1,11 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "BoxLayout.hpp"
#include "Image.hpp"
#include <utf8/UTF8.hpp>
#include "BottomBar.hpp"

namespace gui
{


@@ 13,7 14,7 @@ namespace gui
        Image *image                                                 = nullptr;
        std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr;
        std::function<void()> bottomBarRestoreFromTemporaryMode      = nullptr;
        bool textOnLeft                                              = true;
        BottomBar::Side bottomBarSide                                = BottomBar::Side::LEFT;

        void applyCallbacks();



@@ 23,11 24,11 @@ namespace gui
                 const uint32_t &y,
                 const uint32_t &w,
                 const uint32_t &h,
                 std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr,
                 std::function<void()> bottomBarRestoreFromTemporaryMode      = nullptr,
                 bool textOnLeft                                              = true);
                 const std::function<void(const UTF8 &text)> &bottomBarTemporaryMode = nullptr,
                 const std::function<void()> &bottomBarRestoreFromTemporaryMode      = nullptr,
                 BottomBar::Side bottomBarSide                                       = BottomBar::Side::LEFT);

        void setImageVisible(bool state);
        void setCheck(bool state);
        bool isChecked();
    };


M module-gui/gui/widgets/CheckBoxWithLabel.cpp => module-gui/gui/widgets/CheckBoxWithLabel.cpp +34 -28
@@ 1,42 1,48 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "CheckBoxWithLabel.hpp"

namespace gui
{
    CheckBoxWithLabel::CheckBoxWithLabel(
        Item *parent, int x, int y, UTF8 description, std::function<void(CheckBoxWithLabel &)> clickCallback)
    CheckBoxWithLabel::CheckBoxWithLabel(Item *parent,
                                         uint32_t x,
                                         uint32_t y,
                                         uint32_t w,
                                         uint32_t h,
                                         const UTF8 &description,
                                         const std::function<void(const UTF8 &text)> &bottomBarTemporaryMode,
                                         const std::function<void()> &bottomBarRestoreFromTemporaryMode,
                                         gui::BottomBar::Side textSide)
        : HBox{parent, x, y, w, h}
    {
        auto body = new gui::HBox(nullptr, x, y, style::window::default_body_width, style::window::label::big_h);
        body->setEdges(gui::RectangleEdge::None);

        label =
            new gui::Label(nullptr, 0, 0, style::checkbox::description_width, style::window::label::big_h, description);
        check = new gui::CheckBox(nullptr,
                                  style::checkbox::check_x,
                                  style::checkbox::check_y,
                                  style::checkbox::check_width,
                                  style::window::label::small_h);
        check->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
        setEdges(gui::RectangleEdge::None);

        label->activatedCallback = [=](Item &item) {
            setChecked(!check->isChecked());
            if (clickCallback) {
                clickCallback(*this);
        check =
            new gui::CheckBox(this, 0, 0, 0, 0, bottomBarTemporaryMode, bottomBarRestoreFromTemporaryMode, textSide);
        check->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
        check->setMinimumSize(60, style::window::label::big_h);
        setChecked(true);

        label = new gui::Label(this, 0, 0, 0, 0, description);
        label->setEdges(RectangleEdge::None);
        label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
        label->setMargins(gui::Margins(style::window::default_left_margin, 0, 0, 0));
        label->setFont(style::window::font::big);
        label->setMinimumHeight(style::window::label::big_h);
        label->setMaximumWidth(style::window::default_body_width);

        focusChangedCallback = [&](Item &item) {
            if (focus) {
                label->setFont(style::window::font::bigbold);
            }
            else {
                label->setFont(style::window::font::big);
            }
            return true;
        };

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

        /*
         * We need to add widgets after decorate to correctly redraw them
         */
        parent->addWidget(body);
        body->addWidget(label);
        body->addWidget(check);
        resizeItems();
    }

    bool CheckBoxWithLabel::isChecked() const


@@ 46,6 52,6 @@ namespace gui

    void CheckBoxWithLabel::setChecked(bool state)
    {
        check->setImageVisible(state);
        check->setCheck(state);
    }
} // namespace gui

M module-gui/gui/widgets/CheckBoxWithLabel.hpp => module-gui/gui/widgets/CheckBoxWithLabel.hpp +17 -21
@@ 1,36 1,32 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once
#include <CheckBox.hpp>
#include <Label.hpp>

namespace style::checkbox
{
    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
#include "CheckBox.hpp"
#include "Label.hpp"
#include "BottomBar.hpp"

namespace gui
{
    class CheckBoxWithLabel : public gui::Item
    class CheckBoxWithLabel : public gui::HBox
    {
      private:
        gui::CheckBox *check = nullptr;
        gui::Label *label    = nullptr;

      public:
        CheckBoxWithLabel(Item *parent,
                          int x,
                          int y,
                          UTF8 description,
                          std::function<void(CheckBoxWithLabel &)> checkCallback = nullptr);

        ~CheckBoxWithLabel() override = default;
                          uint32_t x,
                          uint32_t y,
                          uint32_t w,
                          uint32_t h,
                          const UTF8 &description,
                          const std::function<void(const UTF8 &text)> &bottomBarTemporaryMode = nullptr,
                          const std::function<void()> &bottomBarRestoreFromTemporaryMode      = nullptr,
                          BottomBar::Side bottomBarSide                                       = BottomBar::Side::LEFT);

        void setChecked(bool state);
        auto isChecked() const -> bool;

      private:
        gui::CheckBox *check = nullptr;
        gui::Label *label    = nullptr;
    };
} // namespace gui

M module-gui/gui/widgets/RichTextParser.cpp => module-gui/gui/widgets/RichTextParser.cpp +1 -1
@@ 524,7 524,7 @@ namespace gui::text
    {
        log_parser("parsing: %s", text.c_str());
        if (text.empty() || base_style == nullptr) {
            LOG_ERROR("no: %s", text.empty() ? "text" : "base style");
            log_parser("no: %s", text.empty() ? "text" : "base style");
            return nullptr;
        }


M module-gui/gui/widgets/Text.cpp => module-gui/gui/widgets/Text.cpp +1 -2
@@ 209,8 209,7 @@ namespace gui

        if (format.getFont() != newFont) {
            format.setFont(newFont);
            buildCursor();
            drawLines();
            buildDocument(getText());
        }
    }