~aleteoryx/muditaos

ref: ef3f840a4dfa76f16dd009c536782a8b28fec6e9 muditaos/module-apps/application-settings-new/windows/SoundSelectWindow.cpp -rw-r--r-- 2.2 KiB
ef3f840a — Marcin Smoczyński [EGD-6049] Add voice call over HSP 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
// 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-new/ApplicationSettings.hpp"
#include "application-settings-new/models/SoundsModel.hpp"
#include "application-settings-new/widgets/SettingsSoundItem.hpp"
#include "application-settings-new/data/SoundSelectData.hpp"
#include <gui/widgets/ListView.hpp>
#include <i18n/i18n.hpp>

namespace gui
{
    SoundSelectWindow::SoundSelectWindow(app::Application *app, std::string name)
        : AppWindow(app, name), mSoundsModel{std::make_shared<SoundsModel>()}
    {
        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::header::height - 1,
                                        style::listview::body_width_with_scroll,
                                        style::window_height - style::header::height + 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