/**************************************************************************
KitchenAlert
- Copyright (C) 2010 Heli Hyvättinen
+ Copyright (C) 2010-2011 Heli Hyvättinen
This file is part of KitchenAlert.
#include <qdebug.h>
#include <QFile>
#include <QXmlStreamWriter>
-#include <QXmlStreamReader>
Timer::Timer(QObject *parent) :
QObject(parent)
connect(&_actualTimer, SIGNAL(timeout()), this, SLOT(secondPassed()));
alerting_ = false;
-}
+ _remainingTime = 0; //Same as when stopped
+}
int Timer::getOriginalTimeInSeconds()
if (_remainingTime == 0)
{
alerting_ = true;
+ alertSound_.play();
emit alert(whereAmI());
- qDebug() << "alerted";
+// qDebug() << "alerting";
}
emit remainingTimeChanged(); //after alerting in case of alert so that status gets updated immediately
_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...
+
+ 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;
+ alerting_ = true;
+ alertSound_.play();
emit alert(whereAmI());
- qDebug () << "Alerted for 00:00:00 alert";
+// qDebug () << "Alerting 00:00:00 from row: " << whereAmI().row();
}
+
+ else
+ {
+ alerting_ = false;
+ alertSound_.stop();
+ }
+
}
_remainingTime = 0; //Stopped timer shows 00:00:00
alerting_ = false;
+ alertSound_.stop();
}
void Timer::snooze()
_remainingTime = 120;
alerting_ = false;
+ alertSound_.stop();
}
}
+void Timer::enableDefaultSound()
+{
+alertSound_.setDefaultSound();
+}
+
+void Timer::changeAlertSound(QString filename)
+{
+alertSound_.setSound(filename);
+}
+
+
+
+
bool Timer::save(QString filename)
{
QFile file(filename);
_alertText = reader.attributes().value("alert_text").toString();
_originalTime = reader.attributes().value("time_in_seconds").toString().toInt();
- return true;
+ filenameWithPath_ = filename;
+ return true;
+}
+//QString Timer::getFilename()
+//{
+// return filenameWithPath_;
+//}
-}