Screen keep lit when playing
[chessclock] / classes / clockswidget.h
index 72dd641..e629ab3 100644 (file)
@@ -28,7 +28,9 @@
 class QHBoxLayout;
 class QVBoxLayout;
 class QLabel;
-class WelcomeScreenWidget;
+class TurnInformation;
+class QToolButton;
+class ScreenLitKeeper;
 
 class ChessClock;
 
@@ -37,40 +39,41 @@ class ChessClock;
     @author Arto Hyvättinen
     @date 2010-08-14
 
-    Central widget of Chess Clock
+    Central widget of Chess Clock.
+    Needed to create new ClocksWidget to
+    every new game.
 
   */
 class ClocksWidget : public QWidget
 {
     Q_OBJECT
 public:
-    ClocksWidget(QWidget *parent = 0);
-
-    /*! Set clocks and paint them.
-
-      */
-    void setClocks(ChessClock* white, ChessClock* black);
-
+    ClocksWidget(ChessClock* white, ChessClock* black, QWidget *parent = 0);
+    ~ClocksWidget();
+    bool isPlayStarted()  { return (status_!=Welcome); }
 
 protected:
-//    void mouseReleaseEvent(QMouseEvent *event);
+    void mouseReleaseEvent(QMouseEvent *event);
 
-    void initEmptyScreen();
 
 signals:
-    void setupTouch();
+   void TurnFinished(TurnInformation* turnInfo);
+   void ClickedWhenStopped();
 
 public slots:
+   /*! Pause game */
+    void pause();
+    /*! End the game */
+    void stopPlay();
 
 protected:
     ChessClock* white_;
     ChessClock* black_;
 
-    QHBoxLayout* clockLayout_;
-
     QLabel* pauseLabel_;
     QLabel* welcomeLabel_;
-    WelcomeScreenWidget* welcomeScreen_;
+    QToolButton* pauseButton_;
+    ScreenLitKeeper* keeper_;
 
     enum GameStatus {
         Stopped  /*! Not running */,
@@ -78,14 +81,16 @@ protected:
         BlackTurn,
         WhitePause,
         BlackPause,
-        NoClocks,    /*! Clocks not set ! */
         Welcome
         };
 
     GameStatus status_;
     QTime delayTimer_; /*! To avoid double clicks */
 
-    static int const CLICKDELAY = 500 ; /*! Click delay in msecs */
+    int recentX;
+    int recentY;
+
+    static int const CLICKDELAY = 1500 ; /*! Click delay in msecs */