Bugfixes
[kitchenalert] / src / selectsounddialog.cpp
index 210fb90..0a78d3e 100644 (file)
@@ -1,7 +1,7 @@
 /**************************************************************************
         KitchenAlert
 
-        Copyright (C) 2010  Heli Hyvättinen
+        Copyright (C) 2010-2011  Heli Hyvättinen
         
         This file is part of KitchenAlert.
 
 
 #include "selectsounddialog.h"
 #include "ui_selectsounddialog.h"
+#include "alertsound.h"
 #include <QFileDialog>
 #include <QSettings>
 #include <QDebug>
-#include <Phonon>
+
+
 
 SelectSoundDialog::SelectSoundDialog(QWidget *parent) :
     QDialog(parent),
     ui(new Ui::SelectSoundDialog)
 {
+
     ui->setupUi(this);
     connect(ui->browseButton,SIGNAL(clicked()),this,SLOT(browse()));
 
@@ -50,12 +53,12 @@ SelectSoundDialog::SelectSoundDialog(QWidget *parent) :
         ui->lineEdit->setDisabled(true);
     }
     else ui->CustomSoundRadioButton->setChecked(true);
-    qDebug() << "UseDefaultSoundfile is " << useDefaultSoundFile;
+//    qDebug() << "UseDefaultSoundfile is " << useDefaultSoundFile;
 
-    connect(ui->testButton,SIGNAL(clicked()),this,SLOT(testSound()));
-    pSound_ = Phonon::createPlayer(Phonon::NoCategory, Phonon::MediaSource(ui->lineEdit->displayText()));
 
 
+    isTesting_ = false;
+    connect(ui->TestButton,SIGNAL(clicked()),this,SLOT(testSound()));
 }
 
 SelectSoundDialog::~SelectSoundDialog()
@@ -84,8 +87,32 @@ bool SelectSoundDialog::isDefaultSoundChecked()
     return ui->DefaultSoundRadioButton->isChecked();
 }
 
-void SelectSoundDialog::testSound( )
+void SelectSoundDialog::testSound()
 {
-    pSound_->setCurrentSource(ui->lineEdit->displayText());
-    pSound_->play();
+    if (isTesting_ == false)
+    {
+        if  (ui->CustomSoundRadioButton->isChecked() == false)
+        {
+            player.setMedia(QUrl::fromLocalFile(AlertSound::defaultsound_));
+        }
+
+        else
+        {
+            player.setMedia(QUrl::fromLocalFile(ui->lineEdit->displayText()));
+        }
+
+        player.play();
+
+        ui->TestButton->setText(tr("Stop test"));
+
+        isTesting_ = true;
+    }
+
+    else
+    {
+        player.stop();
+        ui->TestButton->setText(tr("Test sound"));
+        isTesting_ = false;
+    }
+
 }