-rw-r--r-- | library/sound.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/library/sound.cpp b/library/sound.cpp index 373fd4c..602fcf0 100644 --- a/library/sound.cpp +++ b/library/sound.cpp @@ -27,2 +27,9 @@ +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <sys/soundcard.h> + +#include "config.h" +#include <qmessagebox.h> #ifndef QT_NO_SOUND @@ -101,7 +108,9 @@ public: { + loopsleft=0; } - void playLoop() + void playLoop(int loopcnt = -1) { // needs server support + loopsleft = loopcnt; @@ -113,6 +122,16 @@ public: - void timerEvent(QTimerEvent*) + void timerEvent ( QTimerEvent *e ) { + if (loopsleft >= 0) { + if (--loopsleft <= 0) + killTimer (e->timerId()); + return; + } play(); } + + bool isFinished ( ) const + { + return ( loopsleft == 0 ); + } @@ -120,2 +139,3 @@ private: QString filename; + int loopsleft; }; @@ -141,3 +161,3 @@ void Sound::play() d->killTimers(); - d->play(); + d->playLoop(1); #endif @@ -160,2 +180,8 @@ void Sound::stop() +bool Sound::isFinished() const +{ +#ifndef QT_NO_SOUND + return d->isFinished(); +#endif +} @@ -163,10 +189,4 @@ void Sound::soundAlarm() { -#ifdef QT_QWS_CUSTOM -# ifndef QT_NO_COP +#ifndef QT_NO_COP QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); -# endif -#else -# ifndef QT_NO_SOUND - QSound::play(Resource::findSound("alarm")); -# endif #endif |