00001 /************************************************************************** 00002 00003 Chess Clock 00004 00005 Copyright (c) Arto Hyvättinen 2010 00006 00007 This file is part of Chess Clock software. 00008 00009 Chess Clock is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 Chess Clock is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 00020 **************************************************************************/ 00021 00022 #ifndef CLOCKSWIDGET_H 00023 #define CLOCKSWIDGET_H 00024 00025 #include <QWidget> 00026 #include <QTime> 00027 00028 class QHBoxLayout; 00029 class QVBoxLayout; 00030 class QLabel; 00031 class TurnInformation; 00032 class QToolButton; 00033 class ScreenLitKeeper; 00034 00035 class ChessClock; 00036 00047 class ClocksWidget : public QWidget 00048 { 00049 Q_OBJECT 00050 public: 00051 ClocksWidget(ChessClock* white, ChessClock* black, QWidget *parent = 0); 00052 ~ClocksWidget(); 00053 bool isPlayStarted() { return (status_!=Welcome); } 00054 00055 protected: 00056 void mouseReleaseEvent(QMouseEvent *event); 00057 bool eventFilter(QObject *obj, QEvent *event); 00058 00059 00060 signals: 00061 void TurnFinished(TurnInformation* turnInfo); 00062 void ClickedWhenStopped(); 00063 00064 public slots: 00066 void pause(); 00068 void stopPlay(); 00069 00070 protected: 00071 ChessClock* white_; 00072 ChessClock* black_; 00073 00074 QLabel* pauseLabel_; 00075 QLabel* welcomeLabel_; 00076 QToolButton* pauseButton_; 00077 ScreenLitKeeper* keeper_; 00078 00079 enum GameStatus { 00080 Stopped , 00081 WhiteTurn, 00082 BlackTurn, 00083 WhitePause, 00084 BlackPause, 00085 Welcome 00086 }; 00087 00088 GameStatus status_; 00089 QTime delayTimer_; 00091 int recentX; 00092 int recentY; 00093 00094 static int const CLICKDELAY = 1500 ; 00098 }; 00099 00100 #endif // CLOCKSWIDGET_H