1283d32ef8f7737ca00b075efdc12b1a0ccc9985
[chessclock] / classes / clockswidget.h
1  /**************************************************************************
2
3     Chess Clock
4
5     Copyright (c) Arto Hyvättinen 2010
6
7     This file is part of Chess Clock software.
8
9     Chess Clock is free software: you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation, either version 3 of the License, or
12     (at your option) any later version.
13
14     Chess Clock is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18
19
20 **************************************************************************/
21
22 #ifndef CLOCKSWIDGET_H
23 #define CLOCKSWIDGET_H
24
25 #include <QWidget>
26 #include <QTime>
27
28 class QHBoxLayout;
29 class QVBoxLayout;
30 class QLabel;
31 class TurnInformation;
32
33 class ChessClock;
34
35 /*! Widget with two clocks
36
37     @author Arto Hyvättinen
38     @date 2010-08-14
39
40     Central widget of Chess Clock.
41     Needed to create new ClocksWidget to
42     every new game.
43
44   */
45 class ClocksWidget : public QWidget
46 {
47     Q_OBJECT
48 public:
49     ClocksWidget(ChessClock* white, ChessClock* black, QWidget *parent = 0);
50     bool isPlayStarted()  { return (status_!=Welcome); }
51
52 protected:
53     void mouseReleaseEvent(QMouseEvent *event);
54
55
56 signals:
57    void TurnFinished(TurnInformation* turnInfo);
58    void ClickedWhenStopped();
59
60 public slots:
61    /*! Pause game */
62     void pause();
63     /*! End the game */
64     void stopPlay();
65
66 protected:
67     ChessClock* white_;
68     ChessClock* black_;
69
70     QLabel* pauseLabel_;
71     QLabel* welcomeLabel_;
72
73     enum GameStatus {
74         Stopped  /*! Not running */,
75         WhiteTurn,
76         BlackTurn,
77         WhitePause,
78         BlackPause,
79         Welcome
80         };
81
82     GameStatus status_;
83     QTime delayTimer_; /*! To avoid double clicks */
84
85     static int const CLICKDELAY = 500 ; /*! Click delay in msecs */
86
87
88
89 };
90
91 #endif // CLOCKSWIDGET_H