Commit 2097d305cc55d12b8aa1ee0db6ed90f6f0ccc0ee
1 parent
b8c0b492fe
Exists in
master
and in
2 other branches
소리 재생 기능 추가
Showing
3 changed files
with
50 additions
and
4 deletions
Show diff stats
app/gui/oven_control/oven_control.pro
| ... | ... | @@ -4,8 +4,7 @@ |
| 4 | 4 | # |
| 5 | 5 | #------------------------------------------------- |
| 6 | 6 | |
| 7 | -QT += core gui | |
| 8 | -QT += network | |
| 7 | +QT += core gui network multimedia | |
| 9 | 8 | |
| 10 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets |
| 11 | 10 | |
| ... | ... | @@ -61,7 +60,8 @@ SOURCES += main.cpp\ |
| 61 | 60 | realtimemain.cpp \ |
| 62 | 61 | realtimepartswindow.cpp \ |
| 63 | 62 | realtimesensorwindow.cpp \ |
| 64 | - bulletindicator.cpp | |
| 63 | + bulletindicator.cpp \ | |
| 64 | + soundplayer.cpp | |
| 65 | 65 | |
| 66 | 66 | HEADERS += mainwindow.h \ |
| 67 | 67 | cook.h \ |
| ... | ... | @@ -111,7 +111,8 @@ HEADERS += mainwindow.h \ |
| 111 | 111 | realtimemain.h \ |
| 112 | 112 | realtimepartswindow.h \ |
| 113 | 113 | realtimesensorwindow.h \ |
| 114 | - bulletindicator.h | |
| 114 | + bulletindicator.h \ | |
| 115 | + soundplayer.h | |
| 115 | 116 | |
| 116 | 117 | FORMS += mainwindow.ui \ |
| 117 | 118 | manualcookwindow.ui \ | ... | ... |
app/gui/oven_control/soundplayer.cpp
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +#include "soundplayer.h" | |
| 2 | + | |
| 3 | +QMap<QString, QSound *> SoundPlayer::map; | |
| 4 | +QSound *SoundPlayer::current = 0; | |
| 5 | + | |
| 6 | +void SoundPlayer::play(const QString &filename) | |
| 7 | +{ | |
| 8 | + if (current && !current->isFinished()) | |
| 9 | + current->stop(); | |
| 10 | + | |
| 11 | + if (map.contains(filename)) | |
| 12 | + current = map.value(filename); | |
| 13 | + else | |
| 14 | + { | |
| 15 | + current = new QSound(filename); | |
| 16 | + map[filename] = current; | |
| 17 | + } | |
| 18 | + | |
| 19 | + current->play(); | |
| 20 | +} | |
| 21 | + | ... | ... |
app/gui/oven_control/soundplayer.h
| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | +#ifndef SOUNDPLAYER_H | |
| 2 | +#define SOUNDPLAYER_H | |
| 3 | + | |
| 4 | +#include <QObject> | |
| 5 | +#include <QSound> | |
| 6 | +#include <QMap> | |
| 7 | + | |
| 8 | +class SoundPlayer : public QObject | |
| 9 | +{ | |
| 10 | + Q_OBJECT | |
| 11 | +public: | |
| 12 | + static void play(const QString &filename); | |
| 13 | + | |
| 14 | +signals: | |
| 15 | + | |
| 16 | +public slots: | |
| 17 | + | |
| 18 | +private: | |
| 19 | + static QMap<QString, QSound *> map; | |
| 20 | + static QSound *current; | |
| 21 | + | |
| 22 | +}; | |
| 23 | + | |
| 24 | +#endif // SOUNDPLAYER_H | ... | ... |