diff --git a/qt/main_window.cpp b/qt/main_window.cpp
index cf967a6..b68fdad 100644
--- a/qt/main_window.cpp
+++ b/qt/main_window.cpp
@@ -97,7 +97,10 @@ MainWindow::MainWindow(QWidget *iParent)
// Make it easier to reproduce bugs
LOG_DEBUG("Rand seed: " << val);
- m_timerModel = new TimerModel;
+ QSettings qs(ORGANIZATION, PACKAGE_NAME);
+ int timerTotal = qs.value(PrefsDialog::kINTF_TIMER_TOTAL_DURATION, 180).toInt();
+ int timerAlert = qs.value(PrefsDialog::kINTF_TIMER_ALERT_DURATION, 30).toInt();
+ m_timerModel = new TimerModel(timerTotal, timerAlert);
// TODO: connect to some of the timer signals (alert() and expired())
QObject::connect(this, SIGNAL(gameChangedNonConst(PublicGame*)),
@@ -163,7 +166,6 @@ MainWindow::MainWindow(QWidget *iParent)
emit gameChanged(NULL);
// Load dictionary
- QSettings qs(ORGANIZATION, PACKAGE_NAME);
QString dicPath = qs.value(PrefsDialog::kINTF_DIC_PATH, "").toString();
if (dicPath != "")
{
@@ -280,6 +282,13 @@ void MainWindow::prefsUpdated()
m_newGameDialog->refresh();
}
+ // Refresh the timer values
+ QSettings qs(ORGANIZATION, PACKAGE_NAME);
+ int timerTotal = qs.value(PrefsDialog::kINTF_TIMER_TOTAL_DURATION).toInt();
+ int timerAlert = qs.value(PrefsDialog::kINTF_TIMER_ALERT_DURATION).toInt();
+ m_timerModel->setTotalDuration(timerTotal);
+ m_timerModel->setAlertDuration(timerAlert);
+
// Probably useless in most cases (currently only used for
// the History alignment)
emit gameUpdated();
diff --git a/qt/prefs_dialog.cpp b/qt/prefs_dialog.cpp
index 35c7004..71cf127 100644
--- a/qt/prefs_dialog.cpp
+++ b/qt/prefs_dialog.cpp
@@ -38,6 +38,8 @@ const QString PrefsDialog::kINTF_WARN_REPLAY_TURN = "Interface/WarnReplayTurn";
const QString PrefsDialog::kINTF_SHOW_TOOLBAR = "Interface/ShowToolBar";
const QString PrefsDialog::kINTF_LINK_TRAINING_7P1 = "Interface/LinkTrainingRackWith7P1";
const QString PrefsDialog::kINTF_DEFAULT_AI_LEVEL = "Interface/DefaultAiLevel";
+const QString PrefsDialog::kINTF_TIMER_TOTAL_DURATION = "Interface/TimerTotalDuration";
+const QString PrefsDialog::kINTF_TIMER_ALERT_DURATION = "Interface/TimerAlertDuration";
const QString PrefsDialog::kDEFAULT_DEF_SITE = "http://fr.wiktionary.org/wiki/%w";
@@ -45,14 +47,19 @@ PrefsDialog::PrefsDialog(QWidget *iParent)
: QDialog(iParent)
{
setupUi(this);
- lineEditDefSite->setToolTip(_("URL of the site used to display word definitions.\n"
- "In the URL, %w will be replaced with the word in lower case. Examples:\n"
- "\thttp://fr.wiktionary.org/wiki/%w\n"
- "\thttp://en.wiktionary.org/wiki/%w\n"
- "\thttp://images.google.com/images?q=%w"));
- spinBoxDefaultLevel->setToolTip(_("Default level for Eliot, "
- "used when creating a new game.\n"
- "Accepted range: [0-100]"));
+ lineEditDefSite->setToolTip(_q("URL of the site used to display word definitions.\n"
+ "In the URL, %w will be replaced with the word in lower case. Examples:\n"
+ "\thttp://fr.wiktionary.org/wiki/%w\n"
+ "\thttp://en.wiktionary.org/wiki/%w\n"
+ "\thttp://images.google.com/images?q=%w"));
+ spinBoxDefaultLevel->setToolTip(_q("Default level for Eliot, "
+ "used when creating a new game.\n"
+ "Accepted range: [0-100]"));
+ spinBoxTimerTotal->setToolTip(_q("Total duration of the timer, in seconds.\n"
+ "Changing this value will reset the timer."));
+ spinBoxTimerAlert->setToolTip(_q("Number of remaining seconds when an alert is triggered.\n"
+ "Use a value of -1 to disable the alert.\n"
+ "Changing this value will reset the timer."));
try
{
@@ -70,6 +77,10 @@ PrefsDialog::PrefsDialog(QWidget *iParent)
checkBoxIntfLinkTraining7P1->setChecked(linkTraining7P1);
int defaultAiLevel = qs.value(kINTF_DEFAULT_AI_LEVEL, 100).toInt();
spinBoxDefaultLevel->setValue(defaultAiLevel);
+ int timerTotal = qs.value(kINTF_TIMER_TOTAL_DURATION, 180).toInt();
+ spinBoxTimerTotal->setValue(timerTotal);
+ int timerAlert = qs.value(kINTF_TIMER_ALERT_DURATION, 30).toInt();
+ spinBoxTimerAlert->setValue(timerAlert);
// Duplicate settings
checkBoxDuplRefuseInvalid->setChecked(Settings::Instance().getBool("duplicate.reject-invalid"));
@@ -142,6 +153,18 @@ void PrefsDialog::updateSettings()
shouldEmitUpdate = true;
qs.setValue(kINTF_DEFAULT_AI_LEVEL, spinBoxDefaultLevel->value());
}
+ if (qs.value(kINTF_TIMER_TOTAL_DURATION, 180).toInt() != spinBoxTimerTotal->value())
+ {
+ // We need to change the default AI level
+ shouldEmitUpdate = true;
+ qs.setValue(kINTF_TIMER_TOTAL_DURATION, spinBoxTimerTotal->value());
+ }
+ if (qs.value(kINTF_TIMER_ALERT_DURATION, 30).toInt() != spinBoxTimerAlert->value())
+ {
+ // We need to change the default AI level
+ shouldEmitUpdate = true;
+ qs.setValue(kINTF_TIMER_ALERT_DURATION, spinBoxTimerAlert->value());
+ }
// Duplicate settings
Settings::Instance().setBool("duplicate.reject-invalid",
diff --git a/qt/prefs_dialog.h b/qt/prefs_dialog.h
index e753aef..e9dcbf0 100644
--- a/qt/prefs_dialog.h
+++ b/qt/prefs_dialog.h
@@ -44,6 +44,8 @@ public:
static const QString kINTF_SHOW_TOOLBAR;
static const QString kINTF_LINK_TRAINING_7P1;
static const QString kINTF_DEFAULT_AI_LEVEL;
+ static const QString kINTF_TIMER_TOTAL_DURATION;
+ static const QString kINTF_TIMER_ALERT_DURATION;
static const QString kDEFAULT_DEF_SITE;
diff --git a/qt/timer_widget.cpp b/qt/timer_widget.cpp
index 2700458..b911b7a 100644
--- a/qt/timer_widget.cpp
+++ b/qt/timer_widget.cpp
@@ -99,6 +99,8 @@ bool TimerModel::isActiveTimer() const
void TimerModel::setTotalDuration(int iSeconds)
{
+ if (iSeconds == m_totalDuration)
+ return;
m_totalDuration = iSeconds;
if (m_totalDuration < 0)
m_totalDuration = 0;
@@ -109,6 +111,8 @@ void TimerModel::setTotalDuration(int iSeconds)
void TimerModel::setAlertDuration(int iSeconds)
{
+ if (iSeconds == m_alertDuration)
+ return;
m_alertDuration = iSeconds;
resetTimer();
}
diff --git a/qt/timer_widget.h b/qt/timer_widget.h
index 6c3c1ef..abe0189 100644
--- a/qt/timer_widget.h
+++ b/qt/timer_widget.h
@@ -35,7 +35,7 @@ class TimerModel : public QObject
Q_OBJECT;
public:
- TimerModel(int iTotalDuration = 8, int iAlertDuration = 3);
+ TimerModel(int iTotalDuration, int iAlertDuration);
// Accessors
int getValue() const { return m_remaining; }
diff --git a/qt/ui/prefs_dialog.ui b/qt/ui/prefs_dialog.ui
index 1592696..a70996b 100644
--- a/qt/ui/prefs_dialog.ui
+++ b/qt/ui/prefs_dialog.ui
@@ -6,8 +6,8 @@
0
0
- 491
- 563
+ 443
+ 629
@@ -108,15 +108,29 @@
-
-
-
-
+
+
-
+
+
+ _("Timer total duration (in seconds):")
+
+
+
+ -
+
+
+ _("Timer alert (in seconds):")
+
+
+
+ -
_("Default computer level:")
- -
+
-
100
@@ -126,8 +140,8 @@
- -
-
+
-
+
Qt::Horizontal
@@ -139,6 +153,29 @@
+ -
+
+
+ 999
+
+
+ 180
+
+
+
+ -
+
+
+ -1
+
+
+ 999
+
+
+ 30
+
+
+
@@ -311,6 +348,8 @@
checkBoxIntfAlignHistory
checkBoxIntfWarnReplayTurn
spinBoxDefaultLevel
+ spinBoxTimerTotal
+ spinBoxTimerAlert
checkBoxDuplRefuseInvalid
spinBoxDuplSoloPlayers
spinBoxDuplSoloValue
@@ -328,8 +367,8 @@
accept()
- 248
- 254
+ 257
+ 619
157
@@ -344,8 +383,8 @@
reject()
- 316
- 260
+ 325
+ 619
286