ClocksWidget: Continue & Stop
authorArto Hyvättinen <arto.hyvattinen@gmail.com>
Sat, 14 Aug 2010 14:42:46 +0000 (17:42 +0300)
committerArto Hyvättinen <arto.hyvattinen@gmail.com>
Sat, 14 Aug 2010 14:42:46 +0000 (17:42 +0300)
classes/clockswidget.cpp
classes/clockswidget.h

index 9882de5..95baa86 100644 (file)
@@ -92,6 +92,15 @@ void ClocksWidget::pause()
     }
 }
 
+void ClocksWidget::stopPlay()
+{
+    if( status_ == BlackTurn || status_ == BlackPause )
+       emit TurnFinished( black_->endTurn());
+    else if( status_ == WhiteTurn || status_ == WhitePause )
+        emit TurnFinished( white_->endTurn());
+    status_ = Stopped;
+}
+
 
 void ClocksWidget::mouseReleaseEvent(QMouseEvent *event)
 {
@@ -117,6 +126,18 @@ void ClocksWidget::mouseReleaseEvent(QMouseEvent *event)
             white_->startTurn();
             status_=WhiteTurn;
             break;
+        case WhitePause:
+            // Continue play
+            white_->continueTurn();
+            status_=WhiteTurn;
+            break;
+        case BlackPause:
+            // Continue play
+            black_->continueTurn();
+            status_=BlackTurn;
+            break;
+        case Stopped:
+            emit ClickedWhenStopped();
 
 
         }
index 88f41a6..7872915 100644 (file)
@@ -55,9 +55,13 @@ protected:
 
 signals:
    void TurnFinished(TurnInformation* turnInfo);
+   void ClickedWhenStopped();
 
 public slots:
+   /*! Pause game */
     void pause();
+    /*! End the game */
+    void stopPlay();
 
 protected:
     ChessClock* white_;