Base class of chess clock.
+ ChessClock has not GUI itself, but it is subclass of QWidget
+ avoiding polymorphism.
+
*/
class ChessClock : public QWidget
{
bool isLoser() const { return loser_; }
int getTurn() const { return turn_; }
+ bool isWhite() const { return isWhite_; }
+ RunningStatus getStatus() const { return status_ ; }
/*! Start new turn */
@return Time available in msecs */
virtual int getTimeAvailable();
+ /*! Get total time played
+ @return Time played in msecs */
+ virtual int getTimePlayed();
+
+ /*! Set time available
+
+ @param msecs Time available in msecs */
+ void setTimeAvailable(int msecs);
+
+ /*! Add time
+
+ Add time to timeAvailableBeforeTurn_ total available time
+ counter.
+
+ @param msecs Time to add in msecs */
+ void addTime(int msecs);
+
+ /*! Get time played current turn.
+ @return Time in msecs */
+ int currentTurnPlayed();
+
+
signals:
- void timeOut();
+ void timeOutLoser();
+ void turnEnded();
+ /*! Emitted after 30 min played one turn.
+
+ Will cause screen not to keeped lit.
+ @since 1.1.2
+ */
+ void dontEatBattery();
public slots:
/*! Refresh clock information */
virtual void repaintClock() = 0;
+ /*! Update clock information, check looser state and refresh */
+ virtual void updateClock();
protected:
ChessClock* another_; /*! Another player's clock */
int turn_; /*! Current turn */
RunningStatus status_;
TurnInformation* currentTurn_;
+ bool dontEatBatteryEmitted_;
- int timePlayed_; /*! Time played in this game */
- int timeAvailableBeforeTurn_; /*! Time available for play BEFORE this turn!*/
+ int timePlayedBeforeTurn_; /*! Time played in this game BEFORE this turn msecs */
+ int timeAvailableBeforeTurn_; /*! Time available for play BEFORE this turn msecs !*/
bool isWhite_; /*! True if white player */
QTimer updateTimer_;
static const int UPDATEINTERVAL = 1000; /** Clock updating interval in msecs */
-
+ static const int DONTEATBATTERYTIME = 30 * 60 * 1000; /*! Time after screen not to keep lit */
};
#endif // CHESSCLOCK_H