Fix a timer bug

This commit is contained in:
Olivier Teulière 2012-11-07 01:08:27 +01:00
parent 7f31fe8b0e
commit f131fa9050
3 changed files with 8 additions and 4 deletions

View file

@ -328,8 +328,8 @@ void MainWindow::prefsUpdated()
// Refresh the timer values
QSettings qs;
int timerTotal = qs.value(PrefsDialog::kINTF_TIMER_TOTAL_DURATION).toInt();
int timerAlert = qs.value(PrefsDialog::kINTF_TIMER_ALERT_DURATION).toInt();
int timerTotal = qs.value(PrefsDialog::kINTF_TIMER_TOTAL_DURATION, 180).toInt();
int timerAlert = qs.value(PrefsDialog::kINTF_TIMER_ALERT_DURATION, 30).toInt();
m_timerModel->setTotalDuration(timerTotal);
m_timerModel->setAlertDuration(timerAlert);

View file

@ -22,6 +22,7 @@
#include <QtGui/QMouseEvent>
#include "timer_widget.h"
#include "debug.h"
INIT_LOGGER(qt, TimerModel);
@ -101,11 +102,10 @@ bool TimerModel::isActiveTimer() const
void TimerModel::setTotalDuration(int iSeconds)
{
ASSERT(iSeconds > 0, "Invalid total duration");
if (iSeconds == m_totalDuration)
return;
m_totalDuration = iSeconds;
if (m_totalDuration < 0)
m_totalDuration = 0;
emit newTotalDuration(m_totalDuration);
resetTimer();
}
@ -113,6 +113,7 @@ void TimerModel::setTotalDuration(int iSeconds)
void TimerModel::setAlertDuration(int iSeconds)
{
// The duration can be negative (to deactivate the alert)
if (iSeconds == m_alertDuration)
return;
m_alertDuration = iSeconds;

View file

@ -48,6 +48,9 @@
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxTimerTotal">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>