From e355acc4fb467230369402b016e9936859b73940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Tue, 6 Nov 2012 23:55:17 +0100 Subject: [PATCH] Reset the timer automatically when a new turn starts --- qt/main_window.cpp | 12 ++++++++++-- qt/main_window.h | 7 ++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/qt/main_window.cpp b/qt/main_window.cpp index 3883b6b..5be8b1f 100644 --- a/qt/main_window.cpp +++ b/qt/main_window.cpp @@ -81,7 +81,7 @@ MainWindow::MainWindow(QWidget *iParent) m_bagWindow(NULL), m_boardWindow(NULL), m_historyWindow(NULL), m_statsWindow(NULL), m_timerWindow(NULL), m_dicToolsWindow(NULL), m_dicNameLabel(NULL), m_timerModel(NULL), - m_currentTurn(0) + m_currentTurn(0), m_lastTurn(0) { #ifdef DEBUG // Check that the string conversion routines are not buggy @@ -116,6 +116,8 @@ MainWindow::MainWindow(QWidget *iParent) this, SLOT(beep())); QObject::connect(m_timerModel, SIGNAL(expired()), this, SLOT(beep())); + QObject::connect(this, SIGNAL(newTurn(int)), + m_timerModel, SLOT(resetTimer())); QObject::connect(this, SIGNAL(gameChangedNonConst(PublicGame*)), this, SLOT(updateForGame(PublicGame*))); @@ -262,12 +264,18 @@ void MainWindow::refresh() m_actionHistoryReplayTurn->setEnabled(!isLastTurn); if (m_game->isFinished()) displayInfoMsg(_q("End of the game")); - // Emit the turnChanged() sign if needed. + // Emit the turnChanged() signal if needed if (currTurn != m_currentTurn) { m_currentTurn = currTurn; emit turnChanged(currTurn, isLastTurn); } + // Emit the newTurn() signal if needed + if (currTurn > m_lastTurn) + { + m_lastTurn = currTurn; + emit newTurn(currTurn); + } // Update the auto-saved game try diff --git a/qt/main_window.h b/qt/main_window.h index 7b3d940..b2e840d 100644 --- a/qt/main_window.h +++ b/qt/main_window.h @@ -62,6 +62,8 @@ signals: void gameChangedNonConst(PublicGame *iGame); void gameUpdated(); void turnChanged(int iCurrTurn, bool isLastTurn); + /// Like turnChanged(), but only emitted when a new turn is created + void newTurn(int iCurrTurn); public slots: /// Display an error message to the user @@ -195,9 +197,12 @@ private: /// Model for the timer widgets TimerModel *m_timerModel; - /// Last known turn number. Used to emit turnChanged(). + /// Current turn number. Used to emit turnChanged(). unsigned m_currentTurn; + /// Last known turn number. Used to emit newTurn(). + unsigned m_lastTurn; + /// Save window state void writeSettings() const; /// Restore window state