From: Arto Hyvättinen Date: Fri, 17 Sep 2010 17:19:06 +0000 (+0300) Subject: Added pause button and screen lit function X-Git-Tag: v1.9.0~84 X-Git-Url: https://vcs.maemo.org/git/?p=chessclock;a=commitdiff_plain;h=6e19ed2103d7494b00e0cfec81f4bedd7d583d72 Added pause button and screen lit function --- diff --git a/chessclock.pro b/chessclock.pro index d30905a..b076cd2 100644 --- a/chessclock.pro +++ b/chessclock.pro @@ -29,7 +29,8 @@ SOURCES += main.cpp\ classes/timecontrol/delayafterclock.cpp \ classes/timecontrol/delayaftertimecontrol.cpp \ classes/timecontrol/hourglassclock.cpp \ - classes/timecontrol/hourglasstimecontrol.cpp + classes/timecontrol/hourglasstimecontrol.cpp \ + classes/screenlitkeeper.cpp HEADERS += chessclockwindow.h \ classes/turninformation.h \ @@ -50,10 +51,11 @@ HEADERS += chessclockwindow.h \ classes/timecontrol/delayafterclock.h \ classes/timecontrol/delayaftertimecontrol.h \ classes/timecontrol/hourglasstimecontrol.h \ - classes/timecontrol/hourglassclock.h + classes/timecontrol/hourglassclock.h \ + classes/screenlitkeeper.h CONFIG += mobility -MOBILITY = +MOBILITY += systeminfo symbian { TARGET.UID3 = 0xeea9c6c5 diff --git a/chessclock.qrc b/chessclock.qrc index 88cc5e6..0f9ca24 100644 --- a/chessclock.qrc +++ b/chessclock.qrc @@ -15,5 +15,6 @@ pic/addbefore.png pic/pauseafter.png pic/pausebefore.png + pic/pausebutton.png diff --git a/chessclockwindow.cpp b/chessclockwindow.cpp index 571f8ec..5d42baa 100644 --- a/chessclockwindow.cpp +++ b/chessclockwindow.cpp @@ -40,6 +40,8 @@ #include #include #include +#include +#include "classes/screenlitkeeper.h" ChessClockWindow::ChessClockWindow(QWidget *parent) : QMainWindow(parent) @@ -61,9 +63,15 @@ 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("New game"), this, SLOT(newGame())); + menuBar()->addAction( keepAction ); menuBar()->addAction( tr("Visit web page"), this, SLOT(visitWeb())); menuBar()->addAction( tr("About"),this, SLOT(about())); menuBar()->addAction(tr("About Qt"), this, SLOT(aboutQt())); diff --git a/classes/clockswidget.cpp b/classes/clockswidget.cpp index 04390b3..f1cc66c 100644 --- a/classes/clockswidget.cpp +++ b/classes/clockswidget.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include ClocksWidget::ClocksWidget(ChessClock *white, ChessClock *black, QWidget *parent): QWidget(parent) @@ -57,12 +59,25 @@ ClocksWidget::ClocksWidget(ChessClock *white, ChessClock *black, QWidget *parent welcomeLabel_->setAlignment( Qt::AlignCenter); welcomeLabel_->setVisible( true ); // Show welcome message + // Pause button + pauseButton_ = new QToolButton; + pauseButton_->setIcon( QIcon(":/rc/pic/pausebutton.png")); + pauseButton_->setIconSize(QSize(75,75)); + connect(pauseButton_, SIGNAL(clicked()), this, SLOT(pause())); + pauseButton_->setVisible(false); + // Put all in layout QVBoxLayout* mainLayout = new QVBoxLayout; mainLayout->addLayout(clockLayout); mainLayout->addWidget(pauseLabel_); mainLayout->addWidget(welcomeLabel_); + QHBoxLayout* pbLayout = new QHBoxLayout; + pbLayout->addStretch(); + pbLayout->addWidget(pauseButton_); + pbLayout->addStretch(); + mainLayout->addLayout(pbLayout); + setLayout( mainLayout); status_ = Welcome; @@ -92,12 +107,14 @@ void ClocksWidget::pause() status_= WhitePause; white_->pauseTurn(); pauseLabel_->setVisible(true); + pauseButton_->setVisible(false); } else if( status_ == BlackTurn) { status_ = BlackPause; black_->pauseTurn(); pauseLabel_->setVisible(true); + pauseButton_->setVisible(false); } } @@ -128,6 +145,7 @@ void ClocksWidget::mouseReleaseEvent(QMouseEvent *event) case Welcome : // Start game! welcomeLabel_->setVisible(false); + pauseButton_->setVisible(true); white_->startTurn(); status_ = WhiteTurn; break; @@ -146,12 +164,14 @@ void ClocksWidget::mouseReleaseEvent(QMouseEvent *event) case WhitePause: // Continue play pauseLabel_->setVisible(false); + pauseButton_->setVisible(true); white_->continueTurn(); status_=WhiteTurn; break; case BlackPause: // Continue play pauseLabel_->setVisible(false); + pauseButton_->setVisible(true); black_->continueTurn(); status_=BlackTurn; break; diff --git a/classes/clockswidget.h b/classes/clockswidget.h index d7e2ba7..8df5a06 100644 --- a/classes/clockswidget.h +++ b/classes/clockswidget.h @@ -29,6 +29,7 @@ class QHBoxLayout; class QVBoxLayout; class QLabel; class TurnInformation; +class QToolButton; class ChessClock; @@ -70,6 +71,7 @@ protected: QLabel* pauseLabel_; QLabel* welcomeLabel_; + QToolButton* pauseButton_; enum GameStatus { Stopped /*! Not running */,