-
Notifications
You must be signed in to change notification settings - Fork 0
/
soundmodel.h
67 lines (54 loc) · 1.44 KB
/
soundmodel.h
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
#ifndef SOUNDMODEL_H
#define SOUNDMODEL_H
#include <QDebug>
#include <QObject>
#include <QStandardItem>
#include <QMediaPlayer>
class SoundModel : public QObject
{
Q_OBJECT
Q_PROPERTY(int type READ type NOTIFY typeChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString imgPath READ imgPath NOTIFY imgPathChanged)
Q_PROPERTY(double masterVolume READ masterVolume WRITE setMasterVolume NOTIFY masterVolumeChanged)
public:
// Constants Type
static const int TYPE_ONE_SHOT = 0;
static const int TYPE_AMBIANT = 1;
static const int TYPE_MUSIC = 2;
static const int TYPE_PLACE = 3;
// Constructor
explicit SoundModel(int type, const QString& name, const QString& imgPath, QObject *parent = 0);
// Getter
int type() const;
QString name() const;
QString imgPath() const;
double masterVolume() const;
// Method
Q_INVOKABLE bool isPlaying();
Q_INVOKABLE void start();
Q_INVOKABLE void stop();
public slots:
// Setter
void setMasterVolume(double masterVolume);
signals:
// Property Signals
void typeChanged();
void nameChanged();
void imgPathChanged();
void masterVolumeChanged();
// Method Signals
void started();
void stopped();
protected:
virtual bool isPlayingSound() = 0;
virtual void startSound() = 0;
virtual void stopSound() = 0;
private:
// Property
int m_type;
QString m_name;
QString m_imgPath;
double m_masterVolume;
};
#endif // SOUNDMODEL_H