From: Arto Hyvättinen Date: Fri, 17 Sep 2010 19:14:08 +0000 (+0300) Subject: Screen keep lit when playing X-Git-Tag: v1.9.0~82 X-Git-Url: http://git.maemo.org/git/?p=chessclock;a=commitdiff_plain;h=4f3147c454280bc975b814ab0328a341473e555a Screen keep lit when playing --- diff --git a/chessclockwindow.cpp b/chessclockwindow.cpp index 5d42baa..43b64cd 100644 --- a/chessclockwindow.cpp +++ b/chessclockwindow.cpp @@ -41,7 +41,6 @@ #include #include #include -#include "classes/screenlitkeeper.h" ChessClockWindow::ChessClockWindow(QWidget *parent) : QMainWindow(parent) @@ -63,13 +62,9 @@ ChessClockWindow::ChessClockWindow(QWidget *parent) connect( start_, SIGNAL(selected(TimeControl*)), this, SLOT(startGame(TimeControl*))); - ScreenLitKeeper* keeper = new ScreenLitKeeper(this); - QAction* keepAction = new QAction( tr("Keep screen lit"), this); - keepAction->setCheckable(true); - connect( keepAction, SIGNAL(triggered(bool)), keeper, SLOT(keepScreenLit(bool))); // Set up menu - menuBar()->addAction( tr("Pause"), this, SLOT(pause())); +// menuBar()->addAction( tr("Pause"), this, SLOT(pause())); // UNUSED - Pause button menuBar()->addAction( tr("New game"), this, SLOT(newGame())); menuBar()->addAction( keepAction ); menuBar()->addAction( tr("Visit web page"), this, SLOT(visitWeb())); diff --git a/classes/clockswidget.cpp b/classes/clockswidget.cpp index f1cc66c..82efa89 100644 --- a/classes/clockswidget.cpp +++ b/classes/clockswidget.cpp @@ -22,6 +22,8 @@ #include "clockswidget.h" #include "chessclock.h" +#include "screenlitkeeper.h" + #include #include #include @@ -92,6 +94,9 @@ ClocksWidget::ClocksWidget(ChessClock *white, ChessClock *black, QWidget *parent delayTimer_.start(); // Initial start recentX = recentY = -1; + + // ScreenLitKeeper to keep screen lit when playing + keeper_ = new ScreenLitKeeper(this); } ClocksWidget::~ClocksWidget() @@ -108,6 +113,8 @@ void ClocksWidget::pause() white_->pauseTurn(); pauseLabel_->setVisible(true); pauseButton_->setVisible(false); + keeper_->keepScreenLit(false); + } else if( status_ == BlackTurn) { @@ -115,6 +122,7 @@ void ClocksWidget::pause() black_->pauseTurn(); pauseLabel_->setVisible(true); pauseButton_->setVisible(false); + keeper_->keepScreenLit(false); } } @@ -146,6 +154,7 @@ void ClocksWidget::mouseReleaseEvent(QMouseEvent *event) // Start game! welcomeLabel_->setVisible(false); pauseButton_->setVisible(true); + keeper_->keepScreenLit(true); white_->startTurn(); status_ = WhiteTurn; break; @@ -163,6 +172,7 @@ void ClocksWidget::mouseReleaseEvent(QMouseEvent *event) break; case WhitePause: // Continue play + keeper_->keepScreenLit(true); pauseLabel_->setVisible(false); pauseButton_->setVisible(true); white_->continueTurn(); @@ -170,6 +180,7 @@ void ClocksWidget::mouseReleaseEvent(QMouseEvent *event) break; case BlackPause: // Continue play + keeper_->keepScreenLit(); pauseLabel_->setVisible(false); pauseButton_->setVisible(true); black_->continueTurn(); diff --git a/classes/clockswidget.h b/classes/clockswidget.h index 8df5a06..e629ab3 100644 --- a/classes/clockswidget.h +++ b/classes/clockswidget.h @@ -30,6 +30,7 @@ class QVBoxLayout; class QLabel; class TurnInformation; class QToolButton; +class ScreenLitKeeper; class ChessClock; @@ -72,6 +73,7 @@ protected: QLabel* pauseLabel_; QLabel* welcomeLabel_; QToolButton* pauseButton_; + ScreenLitKeeper* keeper_; enum GameStatus { Stopped /*! Not running */,