From: Heli Hyvättinen Date: Thu, 10 Feb 2011 18:13:40 +0000 (+0200) Subject: Sound related changes X-Git-Tag: v0.4.0~26 X-Git-Url: https://vcs.maemo.org/git/?p=kitchenalert;a=commitdiff_plain;h=2c155c29c90230a4420dd380a9e027d0d537f1c3 Sound related changes Restored the ability to change the alert sound when there are no alerts Moved to use QtMultimedia instead of Phonon --- diff --git a/src/KitchenAlert.pro b/src/KitchenAlert.pro index cdd89fc..4dd4962 100644 --- a/src/KitchenAlert.pro +++ b/src/KitchenAlert.pro @@ -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 + diff --git a/src/alertsound.cpp b/src/alertsound.cpp index b53541f..1eb0f22 100644 --- a/src/alertsound.cpp +++ b/src/alertsound.cpp @@ -29,12 +29,12 @@ + + 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_)); } diff --git a/src/alertsound.h b/src/alertsound.h old mode 100644 new mode 100755 index 7866d71..eafcfbd --- a/src/alertsound.h +++ b/src/alertsound.h @@ -29,15 +29,13 @@ #include - - -#include +#include /*! 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_; }; diff --git a/src/currentalertstablemodel.h b/src/currentalertstablemodel.h old mode 100644 new mode 100755 index d0e49d6..0d4bb08 --- a/src/currentalertstablemodel.h +++ b/src/currentalertstablemodel.h @@ -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 diff --git a/src/kitchenalertmainwindow.cpp b/src/kitchenalertmainwindow.cpp index c848cd6..42e4a67 100644 --- a/src/kitchenalertmainwindow.cpp +++ b/src/kitchenalertmainwindow.cpp @@ -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); + } + } } diff --git a/src/kitchenalertmainwindow.h b/src/kitchenalertmainwindow.h index 67a90f6..cfe7938 100644 --- a/src/kitchenalertmainwindow.h +++ b/src/kitchenalertmainwindow.h @@ -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. diff --git a/src/main.cpp b/src/main.cpp index 96a27eb..5090c6d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; diff --git a/src/timer.h b/src/timer.h index cbfac47..98d50a5 100644 --- a/src/timer.h +++ b/src/timer.h @@ -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.