X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Ftimer.cpp;h=0b801a1baa0e731f11b4134a729ec04e1b78b060;hb=d12cd0a3066f2b1dc6c4ca596ea3f13ae04117cd;hp=8fac364ef0a18abb123824bbf6c417155aa80dd1;hpb=ae684d7266ec7e510a3a20f7a729418076ad5a84;p=kitchenalert diff --git a/src/timer.cpp b/src/timer.cpp index 8fac364..0b801a1 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -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. @@ -66,15 +68,17 @@ void Timer::setAlertText(QString text) void Timer::secondPassed() { _remainingTime--; - emit remainingTimeChanged(); + 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 } void Timer::start() @@ -82,21 +86,40 @@ void Timer::start() _remainingTime = _originalTime; _actualTimer.start(); + + + 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(); + } + } 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() { _remainingTime = 120; + alerting_ = false; + alertSound_.stop(); } @@ -123,3 +146,14 @@ QModelIndex Timer::whereAmI() } +void Timer::enableDefaultSound() +{ +alertSound_.setDefaultSound(); +} + +void Timer::changeAlertSound(QString filename) +{ +alertSound_.setSound(filename); +} + +