~aleteoryx/muditaos

ref: a8fd5d25ec9589660fcbd316d2dcf13f74542a09 muditaos/module-apps/application-settings/windows/advanced/InformationWindow.cpp -rw-r--r-- 2.9 KiB
a8fd5d25 — Adam Wulkiewicz [MOS-691] Fix memory leaks in APN settings 3 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "InformationWindow.hpp"

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

#include <service-cellular/CellularServiceAPI.hpp>
#include <product/version.hpp>

namespace gui
{

    InformationWindow::InformationWindow(app::ApplicationCommon *app) : AppWindow(app, gui::window::name::information)
    {
        buildInterface();
    }

    void InformationWindow::buildInterface()
    {
        AppWindow::buildInterface();
        navBar->setActive(nav_bar::Side::Right, true);
        navBar->setText(nav_bar::Side::Right, utils::translate(style::strings::common::back));

        setTitle(gui::window::name::information);

        box = new gui::VBox(this, 0, style::window::default_vertical_pos, style::window_width, style::window_height);
        box->setPenWidth(style::window::default_border_no_focus_w);

        addAlignedLabelWithValue(box, "GIT revision:", std::string(GIT_REV));
        addAlignedLabelWithValue(box, "GIT branch:", std::string(GIT_BRANCH));
        addAlignedLabelWithValue(box, "Version:", std::string(VERSION));
        {
            addAlignedLabelWithValue(box, "Bootloader:", utils::translate("not available"));
        }
        std::string firmwareVersion;
        CellularServiceAPI::GetFirmwareVersion(getApplication(), firmwareVersion);
        addAlignedLabelWithValue(
            box, "Modem Frimware:", (firmwareVersion.empty() ? utils::translate("not available") : firmwareVersion));
    }

    void InformationWindow::addAlignedLabelWithValue(BoxLayout *layout,
                                                     const std::string &labelText,
                                                     const std::string &valueText)
    {
        auto lineBox = new gui::VBox(layout, 0, 0, style::window_width, style::window::label::small_h * 2);
        lineBox->setEdges(RectangleEdge::Bottom);

        auto label = new gui::Label(lineBox, 0, 0, 0, 0);
        label->setMinimumHeight(style::window::label::small_h);
        label->setMaximumWidth(style::window_width);
        label->setEdges(RectangleEdge::None);
        label->setMargins(gui::Margins(style::window::default_left_margin, 0, 0, 0));
        label->setText(labelText);
        label->setFont(style::window::font::smallbold);

        auto value = new gui::Label(lineBox, 0, 0, 0, 0);
        value->setMinimumHeight(style::window::label::small_h);
        value->setMaximumWidth(style::window_width);
        value->setEdges(RectangleEdge::None);
        value->setMargins(gui::Margins(0, 0, style::window::default_right_margin, 0));
        value->setAlignment(gui::Alignment::Horizontal::Right);
        value->setText(valueText);
        value->setFont(style::window::font::small);

        lineBox->resizeItems();
        LOG_DEBUG("%s:%s", labelText.c_str(), valueText.c_str());
    }

} // namespace gui