Added the new default sound used in 0.2.0
[kitchenalert] / src / timer.cpp
index 3593008..0b801a1 100644 (file)
@@ -73,8 +73,9 @@ void Timer::secondPassed()
     if (_remainingTime == 0)
     {
         alerting_ = true;
+        alertSound_.play();
         emit alert(whereAmI());
-        qDebug() << "alerting";
+//        qDebug() << "alerting";
     }
 
     emit remainingTimeChanged(); //after alerting in case of alert so that status gets updated immediately
@@ -85,7 +86,21 @@ void Timer::start()
     _remainingTime = _originalTime;
     _actualTimer.start();
 
-    alerting_ = false;
+
+
+    if (_originalTime == 0) //a 00:00:00 alert has to  be checked here, since it's already negative when checked for the next time
+    {
+        alerting_  = true;
+        alertSound_.play();
+        emit alert(whereAmI());
+//        qDebug () << "Alerting 00:00:00 from row: " << whereAmI().row();
+    }
+
+    else
+    {
+        alerting_ = false;
+        alertSound_.stop();
+    }
 
 }
 
@@ -93,9 +108,10 @@ void Timer::start()
 void Timer::stop()
 {
     _actualTimer.stop();
-    _remainingTime = 0; //Stopped timer shows 00:00:00 (which unfortunately makes it red...)
+    _remainingTime = 0; //Stopped timer shows 00:00:00
 
     alerting_ = false;
+    alertSound_.stop();
 }
 
 void Timer::snooze()
@@ -103,6 +119,7 @@ void Timer::snooze()
     _remainingTime = 120;
 
     alerting_ = false;
+    alertSound_.stop();
 }
 
 
@@ -129,3 +146,14 @@ QModelIndex Timer::whereAmI()
 
 }
 
+void Timer::enableDefaultSound()
+{
+alertSound_.setDefaultSound();
+}
+
+void Timer::changeAlertSound(QString filename)
+{
+alertSound_.setSound(filename);
+}
+
+