~aleteoryx/muditaos

ref: 10714ca71dad1e64e531191f88eea58a0ce3fc68 muditaos/module-apps/application-bell-main/windows/BellMainWindow.cpp -rw-r--r-- 1.5 KiB
10714ca7 — Pawel.Paprocki [BH-501] MainMenu 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "BellMainWindow.hpp"
#include <i18n/i18n.hpp>
#include <log/log.hpp>
#include <service-appmgr/Controller.hpp>
#include <gui/input/InputEvent.hpp>
#include <application-bell-main/ApplicationBellMain.hpp>

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

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

        bottomBar->setActive(BottomBar::Side::CENTER, true);
        bottomBar->setText(gui::BottomBar::Side::CENTER, utils::translate(style::strings::common::start));
        setTitle(utils::translate("app_bellmain_main_window_title"));
    }

    bool BellMainWindow::onInput(const InputEvent &inputEvent)
    {
        if (inputEvent.isShortRelease()) {
            switch (inputEvent.getKeyCode()) {
            case KeyCode::KEY_ENTER:
                LOG_INFO("Open MainMenu");
                application->switchWindow(gui::window::name::bell_main_menu, nullptr);
                return true;
            case KeyCode::KEY_RF:
                return true;
            default:
                break;
            }
        }

        // check if any of the lower inheritance onInput methods catch the event
        return AppWindow::onInput(inputEvent);
    }

} // namespace gui