Remove button, fixed column width, limited text & fixed 00:00:00
[kitchenalert] / src / timer.cpp
index 8fac364..e1dba54 100644 (file)
@@ -1,9 +1,11 @@
 /**************************************************************************
-        KitchenAlert v.0.01
+        KitchenAlert
 
         Copyright (C) 2010  Heli Hyvättinen
 
-        This program is free software: you can redistribute it and/or modify
+        This file is part of KitchenAlert.
+
+        Kitchen Alert is free software: you can redistribute it and/or modify
         it under the terms of the GNU General Public License as published by
         the Free Software Foundation, either version 3 of the License, or
         (at your option) any later version.
@@ -38,6 +40,7 @@ Timer::Timer(QObject *parent) :
 }
 
 
+
 int Timer::getOriginalTimeInSeconds()
 {
     return _originalTime;
@@ -66,15 +69,16 @@ void Timer::setAlertText(QString text)
 void Timer::secondPassed()
 {
     _remainingTime--;
-    emit remainingTimeChanged();
+
 
     if (_remainingTime == 0)
     {
         alerting_ = true;
         emit alert(whereAmI());
-        qDebug() << "alerting";
+        qDebug() << "alerted";
     }
 
+    emit remainingTimeChanged(); //after alerting in case of alert so that status gets updated immediately
 }
 
 void Timer::start()
@@ -82,21 +86,31 @@ void Timer::start()
     _remainingTime = _originalTime;
     _actualTimer.start();
 
+    alerting_ = false;
+
+    if (_originalTime == 0) //has to be checked here, since 00:00:00 alert will already be negative when checked next time
+    //THIS ALERTS EVERY SECOND TIME THE TIMER IS STARTED! //This bug disappeared without explanation...
+    {
+        alerting_ = true;
+        emit alert(whereAmI());
+        qDebug () << "Alerted for 00:00:00 alert";
+    }
 }
 
 
 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;
 }
 
 void Timer::snooze()
 {
     _remainingTime = 120;
 
+    alerting_ = false;
 }