~aleteoryx/muditaos

ref: b8239928370663155dc8556354b3715dd387fc5a muditaos/module-apps/application-settings-new/windows/TechnicalInformationWindow.cpp -rw-r--r-- 5.4 KiB
b8239928 — Jakub Pyszczak [EGD-6655] Screen light when active 4 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "TechnicalInformationWindow.hpp"
#include <application-settings-new/ApplicationSettings.hpp>
#include <widgets/Text.hpp>
#include <application-settings-new/widgets/SettingsStyle.hpp>
#include <source/version.hpp>

namespace gui
{

    TechnicalInformationWindow::TechnicalInformationWindow(
        app::Application *app, std::unique_ptr<TechnicalWindowContract::Presenter> technicalPresenter)
        : AppWindow(app, gui::window::name::certification), presenter(std::move(technicalPresenter))
    {
        presenter->attach(this);
        buildInterface();
    }

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

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

        auto vBox = new VBox(this,
                             style::window::default_left_margin,
                             style::header::height + style::margins::very_big,
                             style::window::default_body_width,
                             style::window::default_body_height);
        vBox->setEdges(RectangleEdge::None);

        modelText = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        modelText->setText(utils::translate("app_settings_tech_info_model"));
        modelText->setFont(style::window::font::smallbold);
        modelValue = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        modelValue->setText(presenter->getModel());

        serialNumberText = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        serialNumberText->setFont(style::window::font::smallbold);
        serialNumberText->setText(utils::translate("app_settings_tech_info_serial_number"));
        serialNumberValue = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        serialNumberValue->setText(presenter->getSerial());

        osVersionText = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        osVersionText->setFont(style::window::font::smallbold);
        osVersionText->setText(utils::translate("app_settings_tech_info_os_version"));
        osVersionValue = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        osVersionValue->setText(std::string(VERSION));

        imeiText = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        imeiText->setFont(style::window::font::smallbold);
        imeiText->setText(utils::translate("app_settings_tech_info_imei"));
        imeiValue = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        imeiValue->setText(imei);

        batteryText = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        batteryText->setFont(style::window::font::smallbold);
        batteryText->setText(utils::translate("app_settings_tech_info_battery"));
        batteryValue = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        batteryValue->setText(presenter->getBatteryRev());

        pcbMbText = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        pcbMbText->setText(utils::translate("app_settings_tech_info_pcb_mb"));
        pcbMbText->setFont(style::window::font::smallbold);
        pcbMbValue = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        pcbMbValue->setText(presenter->getPcb(TechnicalWindowPresenter::PCB_MB));

        pcbLmText = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        pcbLmText->setFont(style::window::font::smallbold);
        pcbLmText->setText(utils::translate("app_settings_tech_info_pcb_lm"));
        pcbLmValue = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        pcbLmValue->setText(presenter->getPcb(TechnicalWindowPresenter::PCB_LM));

        pcbAmText = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        pcbAmText->setFont(style::window::font::smallbold);
        pcbAmText->setText(utils::translate("app_settings_tech_info_pcb_am"));
        pcbAmValue = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        pcbAmValue->setText(presenter->getPcb(TechnicalWindowPresenter::PCB_AM));

        pcbUmText = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        pcbUmText->setFont(style::window::font::smallbold);
        pcbUmText->setText(utils::translate("app_settings_tech_info_pcb_um"));
        pcbUmValue = new gui::Text(vBox, 0, 0, style::techinfo::width, style::techinfo::height);
        pcbUmValue->setText(presenter->getPcb(TechnicalWindowPresenter::PCB_UM));

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

    void TechnicalInformationWindow::destroyInterface()
    {
        erase();
        modelText         = nullptr;
        modelValue        = nullptr;
        serialNumberText  = nullptr;
        serialNumberValue = nullptr;
        osVersionText     = nullptr;
        osVersionValue    = nullptr;
        imeiText          = nullptr;
        imeiValue         = nullptr;
    };

    TechnicalInformationWindow::~TechnicalInformationWindow()
    {
        destroyInterface();
    }
} // namespace gui