diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro index 20dfbc5..3fb5ab5 100644 --- a/app/gui/oven_control/oven_control.pro +++ b/app/gui/oven_control/oven_control.pro @@ -4,8 +4,7 @@ # #------------------------------------------------- -QT += core gui -QT += network +QT += core gui network multimedia greaterThan(QT_MAJOR_VERSION, 4): QT += widgets @@ -61,7 +60,8 @@ SOURCES += main.cpp\ realtimemain.cpp \ realtimepartswindow.cpp \ realtimesensorwindow.cpp \ - bulletindicator.cpp + bulletindicator.cpp \ + soundplayer.cpp HEADERS += mainwindow.h \ cook.h \ @@ -111,7 +111,8 @@ HEADERS += mainwindow.h \ realtimemain.h \ realtimepartswindow.h \ realtimesensorwindow.h \ - bulletindicator.h + bulletindicator.h \ + soundplayer.h FORMS += mainwindow.ui \ manualcookwindow.ui \ diff --git a/app/gui/oven_control/soundplayer.cpp b/app/gui/oven_control/soundplayer.cpp new file mode 100644 index 0000000..12440d4 --- /dev/null +++ b/app/gui/oven_control/soundplayer.cpp @@ -0,0 +1,21 @@ +#include "soundplayer.h" + +QMap SoundPlayer::map; +QSound *SoundPlayer::current = 0; + +void SoundPlayer::play(const QString &filename) +{ + if (current && !current->isFinished()) + current->stop(); + + if (map.contains(filename)) + current = map.value(filename); + else + { + current = new QSound(filename); + map[filename] = current; + } + + current->play(); +} + diff --git a/app/gui/oven_control/soundplayer.h b/app/gui/oven_control/soundplayer.h new file mode 100644 index 0000000..611412f --- /dev/null +++ b/app/gui/oven_control/soundplayer.h @@ -0,0 +1,24 @@ +#ifndef SOUNDPLAYER_H +#define SOUNDPLAYER_H + +#include +#include +#include + +class SoundPlayer : public QObject +{ + Q_OBJECT +public: + static void play(const QString &filename); + +signals: + +public slots: + +private: + static QMap map; + static QSound *current; + +}; + +#endif // SOUNDPLAYER_H