~aleteoryx/muditaos

ref: 6b3fdbc99f17803845fa355ddf29a3a94720a746 muditaos/module-apps/application-settings-new/models/AudioSettingsModel.hpp -rw-r--r-- 2.2 KiB
6b3fdbc9 — tomaszkrosnowski [EGD-6613] Audio assets tags are not displayed 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
67
68
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <Application.hpp>

namespace audio
{
    enum class PlaybackType;
}

namespace audio_settings
{
    enum class PlaybackType
    {
        Notifications,
        KeypadSound,
        CallRingtone,
        TextMessageRingtone,
        Alarm
    };

    /// @brief Abstract audio settings model interface class
    class AbstractAudioSettingsModel
    {
      public:
        virtual ~AbstractAudioSettingsModel() noexcept = default;

        [[nodiscard]] virtual bool isVibrationEnabled() = 0;
        virtual void setVibrationEnabled()              = 0;
        virtual void setVibrationDisabled()             = 0;
        [[nodiscard]] virtual bool isSoundEnabled()     = 0;
        virtual void setSoundEnabled()                  = 0;
        virtual void setSoundDisabled()                 = 0;
        /// @return sound file path, returns empty string if not found
        [[nodiscard]] virtual std::string getSound() = 0;
        /// @param sound file path
        virtual void setSound(std::string filePath)     = 0;
        [[nodiscard]] virtual audio::Volume getVolume() = 0;
        virtual void setVolume(audio::Volume vol)       = 0;
        [[nodiscard]] virtual audio::PlaybackType getPlaybackType() = 0;
    };

    class AudioSettingsModel : public AbstractAudioSettingsModel
    {
      public:
        /// @param application application pointer
        /// @param playbackType playback type
        AudioSettingsModel(app::Application *application, PlaybackType playbackType);

        bool isVibrationEnabled() override;
        void setVibrationEnabled() override;
        void setVibrationDisabled() override;
        bool isSoundEnabled() override;
        void setSoundEnabled() override;
        void setSoundDisabled() override;
        std::string getSound() override;
        void setSound(std::string) override;
        audio::Volume getVolume() override;
        void setVolume(audio::Volume vol) override;
        audio::PlaybackType getPlaybackType() override;

      private:
        app::Application *application = nullptr;
        audio::PlaybackType playbackType;
    };
} // namespace audio_settings