~aleteoryx/muditaos

ref: 88a9fdedf22428cbfe52f91c8352eae52438e7f1 muditaos/module-apps/application-desktop/windows/Reboot.cpp -rw-r--r-- 1.7 KiB
88a9fded — Kuba [EGD-6883] Change time settings cleanup 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
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Reboot.hpp"
#include "../ApplicationDesktop.hpp"
#include <Style.hpp>
#include <i18n/i18n.hpp>

namespace gui
{

    RebootWindow::RebootWindow(app::Application *app, std::unique_ptr<PowerOffPresenter> &&presenter)
        : AppWindow(app, app::window::name::desktop_reboot), presenter(std::move(presenter))
    {
        buildInterface();
    }

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

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

        auto text_y_offset = 270;
        auto text_height   = 300;

        text = new Text(
            this,
            style::window::default_left_margin,
            text_y_offset,
            style::window_width - style::window::default_left_margin * 2,
            text_height,
            "Phone have to reboot, press any key to confirm and remove battery for 10 sec to perform full reboot");
        text->setFilled(false);
        text->setBorderColor(gui::ColorFullBlack);
        text->setFont(style::header::font::title);
        text->setEdges(RectangleEdge::None);
        text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
    }

    void RebootWindow::destroyInterface()
    {
        erase();
        invalidate();
    }

    void RebootWindow::invalidate() noexcept
    {
        text = nullptr;
    }

    void RebootWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
    }

    bool RebootWindow::onInput(const InputEvent &inputEvent)
    {
        presenter->powerOff();
        return true;
    }

} /* namespace gui */