projects
/
chessclock
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9c266db
)
Added pause button and screen lit function
author
Arto Hyvättinen
<arto.hyvattinen@gmail.com>
Fri, 17 Sep 2010 17:19:06 +0000
(20:19 +0300)
committer
Arto Hyvättinen
<arto.hyvattinen@gmail.com>
Fri, 17 Sep 2010 17:19:06 +0000
(20:19 +0300)
chessclock.pro
patch
|
blob
|
history
chessclock.qrc
patch
|
blob
|
history
chessclockwindow.cpp
patch
|
blob
|
history
classes/clockswidget.cpp
patch
|
blob
|
history
classes/clockswidget.h
patch
|
blob
|
history
diff --git
a/chessclock.pro
b/chessclock.pro
index
d30905a
..
b076cd2
100644
(file)
--- 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/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 \
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/delayafterclock.h \
classes/timecontrol/delayaftertimecontrol.h \
classes/timecontrol/hourglasstimecontrol.h \
- classes/timecontrol/hourglassclock.h
+ classes/timecontrol/hourglassclock.h \
+ classes/screenlitkeeper.h
CONFIG += mobility
CONFIG += mobility
-MOBILITY =
+MOBILITY += systeminfo
symbian {
TARGET.UID3 = 0xeea9c6c5
symbian {
TARGET.UID3 = 0xeea9c6c5
diff --git
a/chessclock.qrc
b/chessclock.qrc
index
88cc5e6
..
0f9ca24
100644
(file)
--- a/
chessclock.qrc
+++ b/
chessclock.qrc
@@
-15,5
+15,6
@@
<file>pic/addbefore.png</file>
<file>pic/pauseafter.png</file>
<file>pic/pausebefore.png</file>
<file>pic/addbefore.png</file>
<file>pic/pauseafter.png</file>
<file>pic/pausebefore.png</file>
+ <file>pic/pausebutton.png</file>
</qresource>
</RCC>
</qresource>
</RCC>
diff --git
a/chessclockwindow.cpp
b/chessclockwindow.cpp
index
571f8ec
..
5d42baa
100644
(file)
--- a/
chessclockwindow.cpp
+++ b/
chessclockwindow.cpp
@@
-40,6
+40,8
@@
#include <QMessageBox>
#include <QStackedWidget>
#include <QProcess>
#include <QMessageBox>
#include <QStackedWidget>
#include <QProcess>
+#include <QAction>
+#include "classes/screenlitkeeper.h"
ChessClockWindow::ChessClockWindow(QWidget *parent)
: QMainWindow(parent)
ChessClockWindow::ChessClockWindow(QWidget *parent)
: QMainWindow(parent)
@@
-61,9
+63,15
@@
ChessClockWindow::ChessClockWindow(QWidget *parent)
connect( start_, SIGNAL(selected(TimeControl*)), this, SLOT(startGame(TimeControl*)));
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()));
// 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()));
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
(file)
--- a/
classes/clockswidget.cpp
+++ b/
classes/clockswidget.cpp
@@
-30,6
+30,8
@@
#include <QFont>
#include <cstdlib>
#include <QMouseEvent>
#include <QFont>
#include <cstdlib>
#include <QMouseEvent>
+#include <QToolButton>
+#include <QSize>
ClocksWidget::ClocksWidget(ChessClock *white, ChessClock *black, QWidget *parent):
QWidget(parent)
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
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_);
// 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;
setLayout( mainLayout);
status_ = Welcome;
@@
-92,12
+107,14
@@
void ClocksWidget::pause()
status_= WhitePause;
white_->pauseTurn();
pauseLabel_->setVisible(true);
status_= WhitePause;
white_->pauseTurn();
pauseLabel_->setVisible(true);
+ pauseButton_->setVisible(false);
}
else if( status_ == BlackTurn)
{
status_ = BlackPause;
black_->pauseTurn();
pauseLabel_->setVisible(true);
}
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);
case Welcome :
// Start game!
welcomeLabel_->setVisible(false);
+ pauseButton_->setVisible(true);
white_->startTurn();
status_ = WhiteTurn;
break;
white_->startTurn();
status_ = WhiteTurn;
break;
@@
-146,12
+164,14
@@
void ClocksWidget::mouseReleaseEvent(QMouseEvent *event)
case WhitePause:
// Continue play
pauseLabel_->setVisible(false);
case WhitePause:
// Continue play
pauseLabel_->setVisible(false);
+ pauseButton_->setVisible(true);
white_->continueTurn();
status_=WhiteTurn;
break;
case BlackPause:
// Continue play
pauseLabel_->setVisible(false);
white_->continueTurn();
status_=WhiteTurn;
break;
case BlackPause:
// Continue play
pauseLabel_->setVisible(false);
+ pauseButton_->setVisible(true);
black_->continueTurn();
status_=BlackTurn;
break;
black_->continueTurn();
status_=BlackTurn;
break;
diff --git
a/classes/clockswidget.h
b/classes/clockswidget.h
index
d7e2ba7
..
8df5a06
100644
(file)
--- a/
classes/clockswidget.h
+++ b/
classes/clockswidget.h
@@
-29,6
+29,7
@@
class QHBoxLayout;
class QVBoxLayout;
class QLabel;
class TurnInformation;
class QVBoxLayout;
class QLabel;
class TurnInformation;
+class QToolButton;
class ChessClock;
class ChessClock;
@@
-70,6
+71,7
@@
protected:
QLabel* pauseLabel_;
QLabel* welcomeLabel_;
QLabel* pauseLabel_;
QLabel* welcomeLabel_;
+ QToolButton* pauseButton_;
enum GameStatus {
Stopped /*! Not running */,
enum GameStatus {
Stopped /*! Not running */,