From 83ca0f4806ed30fb974420db4171201c451fb583 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Sat, 4 Jul 2009 21:24:20 +0100
Subject: Ding on new messages.


diff --git a/Swift/QtUI/QtSoundPlayer.cpp b/Swift/QtUI/QtSoundPlayer.cpp
index 937d077..5dd3db3 100644
--- a/Swift/QtUI/QtSoundPlayer.cpp
+++ b/Swift/QtUI/QtSoundPlayer.cpp
@@ -3,14 +3,16 @@
 #include <phonon/MediaObject>
 #include <phonon/AudioOutput>
 
+
 namespace Swift{
 	
 QtSoundPlayer::QtSoundPlayer() {
 	audioOutput_ = new Phonon::AudioOutput(Phonon::NotificationCategory);
 	
 	messageReceived_ = new Phonon::MediaObject();
-	messageReceived_->setCurrentSource(Phonon::MediaSource(":/sounds/messageReceived.wav"));
-	Phonon::Path path = Phonon::createPath(messageReceived_, audioOutput_);
+	messageReceived_->setCurrentSource(Phonon::MediaSource(":/sounds/message-received.wav"));
+	Phonon::createPath(messageReceived_, audioOutput_);
+	connect(messageReceived_, SIGNAL(finished()), this, SLOT(handleFinished()));
 }
 
 QtSoundPlayer::~QtSoundPlayer() {
@@ -21,9 +23,14 @@ QtSoundPlayer::~QtSoundPlayer() {
 void QtSoundPlayer::playSound(SoundEffect sound) {
 	switch (sound) {
 		case MessageReceived: 
+			//messageReceived_->stop();
 			messageReceived_->play();
 			break;
 	}
 }
 
+void QtSoundPlayer::handleFinished() {
+	messageReceived_->stop();
+}
+
 }
\ No newline at end of file
diff --git a/Swift/QtUI/QtSoundPlayer.h b/Swift/QtUI/QtSoundPlayer.h
index e0ccf18..b9109a7 100644
--- a/Swift/QtUI/QtSoundPlayer.h
+++ b/Swift/QtUI/QtSoundPlayer.h
@@ -2,6 +2,7 @@
 
 #include "Swift/Controllers/SoundPlayer.h"
 
+#include <QObject>
 
 namespace Phonon {
 	class AudioOutput;
@@ -9,7 +10,8 @@ namespace Phonon {
 }
 
 namespace Swift {
-	class QtSoundPlayer : public SoundPlayer{
+	class QtSoundPlayer : public QObject, public SoundPlayer {
+		Q_OBJECT
 		public:
 			QtSoundPlayer();
 			~QtSoundPlayer();
@@ -17,5 +19,7 @@ namespace Swift {
 		private:
 			Phonon::AudioOutput* audioOutput_;
 			Phonon::MediaObject* messageReceived_;
+		private slots:
+			void handleFinished();
 	};
 }
-- 
cgit v0.10.2-6-g49f6