~aleteoryx/muditaos

ref: f7350c4d44d88f8df856d5e521bce3a32d6034cb muditaos/module-apps/application-settings-new/windows/KeypadLightWindow.cpp -rw-r--r-- 1.8 KiB
f7350c4d — Lucjan Bryndza [EGD-4181] Indexer service scan files (#914) 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "KeypadLightWindow.hpp"

#include "CheckBoxWithLabel.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();
    }

    void KeypadLightWindow::buildInterface()
    {
        BaseSettingsWindow::buildInterface();
        setTitle(utils::localize.get("app_settings_display_keypad_light"));

        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());
                }
            }
        };

        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));

        addWidget(body);
        setFocusItem(body);
    }

} // namespace gui