~aleteoryx/muditaos

ref: c2cd94a6f2aa3f54ba0559928a5f21e4fc042584 muditaos/module-apps/application-music-player/windows/MusicPlayerEmptyWindow.cpp -rw-r--r-- 2.5 KiB
c2cd94a6 — KacperLewandowski [EGD-4417] Fix operations in calculator 5 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
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "MusicPlayerEmptyWindow.hpp"
#include "application-music-player/ApplicationMusicPlayer.hpp"
#include "application-music-player/data/MusicPlayerStyle.hpp"

#include <Style.hpp>
#include <i18n/i18n.hpp>
#include <log/log.hpp>
#include <service-audio/AudioServiceAPI.hpp>

namespace gui
{
    using namespace musicPlayerStyle::emptyWindow;

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

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

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

        bottomBar->setText(BottomBar::Side::LEFT, utils::localize.get("app_music_player_music_library"));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get("app_music_player_quit"));

        topBar->setActive(TopBar::Elements::TIME, true);

        img = new gui::Image(this, noteImg::x, noteImg::y, "note");

        text = new Text(this, infoText::x, infoText::y, infoText::w, infoText::h);
        text->setText(utils::localize.get("app_music_player_music_empty_window_notification"));
        text->setTextType(TextType::MultiLine);
        text->setEditMode(EditMode::Browse);
        text->setEdges(RectangleEdge::None);
        text->setFont(style::window::font::medium);
        text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));

        placeHolder = new gui::Image(this, placeHolderImg::x, placeHolderImg::y, "placeholder_player");
    }

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

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

    bool MusicPlayerEmptyWindow::onDatabaseMessage(sys::Message *msgl)
    {
        return false;
    }

    bool MusicPlayerEmptyWindow::onInput(const InputEvent &inputEvent)
    {
        if (AppWindow::onInput(inputEvent)) {
            return true;
        }

        if (!inputEvent.isShortPress()) {
            return false;
        }

        if (inputEvent.is(gui::KeyCode::KEY_LF)) {
            application->switchWindow(gui::name::window::all_songs_window);
            return true;
        }

        return false;
    }

} /* namespace gui */