~aleteoryx/muditaos

ref: bc737e93f697de2dda221f8f97f0ce0ff05edd0b muditaos/module-apps/application-desktop/windows/PostUpdateWindow.cpp -rw-r--r-- 2.6 KiB
bc737e93 — Przemyslaw Brudny [EGD-5885] Added SimLockHandler 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "PostUpdateWindow.hpp"

#include <locks/data/LockStyle.hpp>
#include <application-desktop/data/DesktopData.hpp>
#include <application-desktop/windows/Names.hpp>

#include <i18n/i18n.hpp>

using namespace gui;

PostUpdateWindow::PostUpdateWindow(app::Application *app)
    : AppWindow(app, app::window::name::desktop_post_update_window)
{
    buildInterface();
}

void PostUpdateWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
    if (data == nullptr) {
        LOG_ERROR("Received null pointer");
    }
    else {
        auto *item = dynamic_cast<CurrentOsVersion *>(data);
        if (item != nullptr) {
            currentOsVersion = item->getCurrentOsVersion();
            auto info        = utils::translate("app_desktop_update_success");
            utils::findAndReplaceAll(info, "$VERSION", currentOsVersion);
            infoIcon->text->setText(info);
        }
    }
    setVisibleState();
}

void PostUpdateWindow::setVisibleState()
{
    bottomBar->setActive(BottomBar::Side::CENTER, true);
}

bool PostUpdateWindow::onInput(const InputEvent &inputEvent)
{
    if (inputEvent.isShortRelease(KeyCode::KEY_ENTER) && bottomBar->isActive(BottomBar::Side::CENTER)) {
        application->switchWindow(gui::name::window::main_window);
        return true;
    }
    return AppWindow::onInput(inputEvent);
}

void PostUpdateWindow::rebuild()
{
    destroyInterface();
    buildInterface();
}

top_bar::Configuration PostUpdateWindow::configureTopBar(top_bar::Configuration appConfiguration)
{
    appConfiguration.enable(top_bar::Indicator::Time);
    appConfiguration.disable(top_bar::Indicator::Lock);
    appConfiguration.disable(top_bar::Indicator::Battery);
    appConfiguration.disable(top_bar::Indicator::Signal);
    appConfiguration.disable(top_bar::Indicator::SimCard);
    return appConfiguration;
}

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

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

    bottomBar->setText(BottomBar::Side::CENTER, utils::translate("common_ok"));

    infoIcon = new gui::Icon(this,
                             style::window::default_left_margin,
                             style::header::height,
                             style::window::default_body_width,
                             style::window::default_body_height,
                             "circle_success",
                             "");
    infoIcon->setAlignment(Alignment::Horizontal::Center);
}

void PostUpdateWindow::destroyInterface()
{
    erase();
}