~aleteoryx/muditaos

ref: 588925f30a1a0e862dc074c15b6fa1711443c6e8 muditaos/module-apps/application-settings/windows/apps/SoundSelectWindow.cpp -rw-r--r-- 2.2 KiB
588925f3 — Wojtek Rzepecki [EGD-7297] Fix callog icons 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SoundSelectWindow.hpp"

#include <application-settings/data/SoundSelectData.hpp>
#include <application-settings/models/apps/SoundsModel.hpp>

#include <ListView.hpp>
#include <i18n/i18n.hpp>

namespace gui
{
    SoundSelectWindow::SoundSelectWindow(app::ApplicationCommon *app,
                                         std::string name,
                                         std::shared_ptr<AbstractSoundsModel> model)
        : AppWindow(app, name), mSoundsModel{std::move(model)}
    {
        buildInterface();
    }

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

    void SoundSelectWindow::buildInterface()
    {
        AppWindow::buildInterface();
        bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::select));
        bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));

        mSoundsList = new gui::ListView(this,
                                        style::window::default_left_margin,
                                        style::window::default_vertical_pos - 1,
                                        style::listview::body_width_with_scroll,
                                        style::window_height - style::window::default_vertical_pos + 1 -
                                            style::footer::height + style::margins::small,
                                        mSoundsModel,
                                        listview::ScrollBarType::Proportional);

        setFocusItem(mSoundsList);
    }

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

    void SoundSelectWindow::onBeforeShow([[maybe_unused]] ShowMode mode, SwitchData *data)
    {
        auto info = dynamic_cast<SoundSelectData *>(data);
        if (info == nullptr) {
            LOG_ERROR("Null switch data pointer!");
            return;
        }

        setTitle(info->get().windowTitle);
        mSoundsModel->createData(application, info->get().audioModel);
    }
} // namespace gui