~aleteoryx/muditaos

ref: 3afcbd8f941738955b306cdefe4f76ea2217c74b muditaos/module-apps/application-settings-new/windows/TechnicalInformationWindow.cpp -rw-r--r-- 4.8 KiB
3afcbd8f — lblach [EGD-6267] Create Technical Information Window 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
// 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>

static constexpr auto model        = "1.0";
static constexpr auto serialNumber = "XXXXXXXXXXXXXXX";
static constexpr auto imei         = "AA-BBBBBB-CCCCCC-D";

namespace gui
{
    TechnicalInformationWindow::TechnicalInformationWindow(app::Application *app)
        : AppWindow(app, gui::window::name::certification)
    {
        buildInterface();
    }

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

        setTitle(utils::localize.get("app_settings_technical_information"));

        modelText  = new gui::Text(this,
                                  style::techinfo::textmodel::x,
                                  style::techinfo::textmodel::y,
                                  style::techinfo::textmodel::width,
                                  style::techinfo::textmodel::height);
        modelValue = new gui::Text(this,
                                   style::techinfo::valuemodel::x,
                                   style::techinfo::valuemodel::y,
                                   style::techinfo::valuemodel::width,
                                   style::techinfo::valuemodel::height);

        serialNumberText  = new gui::Text(this,
                                         style::techinfo::textserialnumber::x,
                                         style::techinfo::textserialnumber::y,
                                         style::techinfo::textserialnumber::width,
                                         style::techinfo::textserialnumber::height);
        serialNumberValue = new gui::Text(this,
                                          style::techinfo::valueserialnumber::x,
                                          style::techinfo::valueserialnumber::y,
                                          style::techinfo::valueserialnumber::width,
                                          style::techinfo::valueserialnumber::height);

        osVersionText  = new gui::Text(this,
                                      style::techinfo::textosversion::x,
                                      style::techinfo::textosversion::y,
                                      style::techinfo::textosversion::width,
                                      style::techinfo::textosversion::height);
        osVersionValue = new gui::Text(this,
                                       style::techinfo::valueosversion::x,
                                       style::techinfo::valueosversion::y,
                                       style::techinfo::valueosversion::width,
                                       style::techinfo::valueosversion::height);

        imeiText  = new gui::Text(this,
                                 style::techinfo::textimea::x,
                                 style::techinfo::textimea::y + 10,
                                 style::techinfo::textimea::width,
                                 style::techinfo::textimea::height);
        imeiValue = new gui::Text(this,
                                  style::techinfo::valueimea::x,
                                  style::techinfo::valueimea::y + 20,
                                  style::techinfo::valueimea::width,
                                  style::techinfo::valueimea::height);

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

    void TechnicalInformationWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        // dummy data for now
        modelText->setText(utils::localize.get("app_settings_tech_info_model"));
        modelValue->setText(model);
        serialNumberText->setText(utils::localize.get("app_settings_tech_info_serial_number"));
        serialNumberValue->setText(serialNumber);
        osVersionText->setText(utils::localize.get("app_settings_tech_info_os_version"));
        osVersionValue->setText(std::string(VERSION));
        imeiText->setText(utils::localize.get("app_settings_tech_info_imei"));
        imeiValue->setText(imei);
    }

    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