Sound related changes
authorHeli Hyvättinen <heli.hyvattinen@kymp.net>
Thu, 10 Feb 2011 18:13:40 +0000 (20:13 +0200)
committerHeli Hyvättinen <heli@pantteri.(none)>
Thu, 10 Feb 2011 18:13:40 +0000 (20:13 +0200)
Restored the ability to change the alert sound when there are no alerts
Moved to use QtMultimedia instead of Phonon

src/KitchenAlert.pro
src/alertsound.cpp
src/alertsound.h [changed mode: 0644->0755]
src/currentalertstablemodel.h [changed mode: 0644->0755]
src/kitchenalertmainwindow.cpp
src/kitchenalertmainwindow.h
src/main.cpp
src/timer.h

index cdd89fc..4dd4962 100644 (file)
@@ -5,7 +5,8 @@
 #-------------------------------------------------
 
 QT       += core gui
-QT      += phonon
+
+
 
 TARGET = KitchenAlert
 TEMPLATE = app
@@ -41,3 +42,7 @@ symbian {
 
 RESOURCES += \
     kitchenalert.qrc
+
+CONFIG += mobility
+MOBILITY += multimedia
+
index b53541f..1eb0f22 100644 (file)
 
 
 
+
+
 AlertSound::AlertSound(QObject *parent) :
     QObject(parent)
 {
 
-    //THIS NEEDS TESTING: DOES IT REALLY CHANGE TUNE WHEN RESTARTING THE APPLICATION?
-
     defaultsound_ = "/home/opt/KitchenAlert/Doorbell-old-tring-modified-multiplied-low-quality.mp3";
     QString filename;
 
@@ -52,7 +52,25 @@ AlertSound::AlertSound(QObject *parent) :
     {
         filename = settings.value("soundfile",defaultsound_).toString();
     }
-    pSound_ = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource(filename));
+
+
+
+      pSound_ = new QMediaPlayer;
+      pSound_->setMedia(QUrl::fromLocalFile(filename));
+ //   player->setVolume(50);
+
+
+/* NOTE:
+   sound priorities are set in /usr/share/policy/etc/current/pulse/xpolicy.conf
+
+This block needs to be appended to this file in the postinstall script
+[stream]
+exe = kitchenalert
+group   = alarm
+
+*/
+
+
 }
 
 AlertSound::~AlertSound()
@@ -66,32 +84,28 @@ AlertSound::~AlertSound()
 
 void AlertSound::play()
 {
-    pSound_->stop(); //Just testing if stopping the previous alert will prevent the jammming of the sound (only partially, but since it helped some, keeping it even if the problem was solved otherwise)
-    pSound_->play();
-    qDebug() << "Sound should be played now";
+     pSound_->play();
+  //  qDebug() << "Sound should be played now";
 }
 
 void AlertSound::stop()
 {
 
     pSound_->stop();
-    qDebug() << pSound_->state();
-    qDebug() << "Sound stopped by AlertSound.";
+//    qDebug() << pSound_->state();
+//    qDebug() << "Sound stopped by AlertSound.";
 }
 
 
 
 void AlertSound::setSound(QString filename)
 {
-   QSettings settings("KitchenAlert","KitchenAlert");
-   settings.setValue("UseDefaultSound",false);
-   settings.setValue("soundfile",filename);
-   pSound_->setCurrentSource(filename);
+
+   pSound_->setMedia(QUrl::fromLocalFile(filename));
 }
 
 void AlertSound::setDefaultSound()
 {
-    QSettings settings ("KitchenAlert","KitchenAlert");
-    settings.setValue("UseDefaultSound",true);
-    pSound_->setCurrentSource(defaultsound_);
+
+    pSound_->setMedia(QUrl::fromLocalFile(defaultsound_));
 }
old mode 100644 (file)
new mode 100755 (executable)
index 7866d71..eafcfbd
 
 #include <QObject>
 
-
-
-#include <Phonon>
+#include <QMediaPlayer>
 
 
 /*! Class for playing the alert sound'
 
   @author Heli Hyvättinen
-  @date 2010-09-27
+  @date 2011-02-10
   @version 0.2.0
 
 Class for playing (and stopping) the alert sound.
@@ -71,8 +69,8 @@ private:
 
 
 
-    Phonon::MediaObject *pSound_;
-    QString defaultsound_;
+   QMediaPlayer *pSound_;
+   QString defaultsound_;
 
 
 };
old mode 100644 (file)
new mode 100755 (executable)
index d0e49d6..0d4bb08
@@ -35,8 +35,8 @@
 /*! Class that contains the model that holds the timers'
 
   @author Heli Hyvättinen
-  @date 2010-09-27
-  @version 0.1.1
+  @date 2011-02-10
+  @version 0.2.0
 
 Class that contains the model that holds the timers
 
index c848cd6..42e4a67 100644 (file)
@@ -286,10 +286,23 @@ void KitchenAlertMainWindow::openSelectSoundDialog()
     SelectSoundDialog dialog;
    if ( dialog.exec() == QDialog::Accepted) //if user pressed OK
     {
+       QSettings settings ("KitchenAlert","KitchenAlert");
+
        if (dialog.isDefaultSoundChecked() == true)
+       {
+
+           settings.setValue("UseDefaultSound",true);
+
            emit defaultSoundEnabled();
+       }
        else
-           emit soundChanged(dialog.getSoundFileName());
+       {
+           QString filename = dialog.getSoundFileName();
+           settings.setValue("UseDefaultSound",false);
+           settings.setValue("soundfile",filename);
+           emit soundChanged(filename);
+       }
+
     }
 
 }
index 67a90f6..cfe7938 100644 (file)
@@ -40,7 +40,7 @@ namespace Ui {
 /*! The main window class of KitchenAlert'
 
   @author Heli Hyvättinen
-  @date 2010-11-24
+  @date 2011-02-10
   @version 0.2.0
 
 Operates the UI.
@@ -148,7 +148,6 @@ private:
     */
     QModelIndex selectedRow();
 
-    AlertSound alertSound_; /*! Takes care of alert sound */ //This has been moved to the timers themselves
 
     /*!
     Not used. Would allow getting rid of the default sound if used.
index 96a27eb..5090c6d 100644 (file)
@@ -28,7 +28,7 @@
 int main(int argc, char *argv[])
 {
     QApplication a(argc, argv);
-    a.setApplicationName("KitchenAlert"); //a name is required by phonon
+    a.setApplicationName("KitchenAlert"); //a name is required to connect to DBus
     a.setApplicationVersion("0.2.0");
     a.setOrganizationName("KitchenAlert");
     KitchenAlertMainWindow w;
index cbfac47..98d50a5 100644 (file)
@@ -39,8 +39,8 @@
 /*! The timer class of KitchenAlert'
 
   @author Heli Hyvättinen
-  @date 2010-09-08
-  @version 0.1.1
+  @date 2011-02-10
+  @version 0.2.0
 
 The timer class of KitchenAlert.