Application Name and version set.
Window icon and title set.
<file>pic/loser.png</file>
<file>pic/white_blue.png</file>
<file>pic/white_gray.png</file>
+ <file>pic/chessclock.png</file>
</qresource>
</RCC>
#include "classes/chessclockwidget.h"
+#include <QIcon>
+#include <QApplication>
+
ChessClockWindow::ChessClockWindow(QWidget *parent)
: QMainWindow(parent)
{
+ setWindowIcon( QIcon(":/rc/pic/chessclock.png"));
+ setWindowTitle( QString("%1 %2").arg(qApp->applicationName()).arg(qApp->applicationVersion()) );
+
ChessClockWidget* widget = new ChessClockWidget(true, this);
setCentralWidget(widget);
+ widget->startTurn();
}
// Set updating timer
updateTimer_.setInterval( UPDATEINTERVAL );
- connect( &updateTimer_, SIGNAL(timeout),this,SLOT(updateClock()));
+ connect( &updateTimer_, SIGNAL(timeout()),this,SLOT(updateClock()));
}
void ChessClock::startTurn()
// Turn information for this new turn
currentTurn_ = new TurnInformation(turn_, isWhite_);
clockTime_.restart();
+ updateTimer_.start();
status_=Running;
// Repaint clock
void ChessClock::pauseTurn()
{
+ updateTimer_.stop();
// Update turn time
currentTurn_->addTime( clockTime_.restart() );
status_ = Paused;
// Add pause duration to information object
currentTurn_->addPause( clockTime_.restart() );
status_ = Running;
+ updateTimer_.start();
updateClock();
}
TurnInformation* ChessClock::endTurn()
{
status_ = NotRunning;
+ updateTimer_.stop();
// Update turn time
currentTurn_->addTime( clockTime_.restart());
// Count time played
currentTurn_->turnReady(timeAvailableBeforeTurn_ );
TurnInformation* information = currentTurn_;
currentTurn_ = 0;
+ emit endTurn();
return information;
}
// Most simple - will be overwritten in more complex time controls:
// subtract duration time!
if( currentTurn_)
+ {
+ // Update turn time
+ currentTurn_->addTime( clockTime_.restart());
return timeAvailableBeforeTurn_-currentTurn_->getDuration();
+ }
else
return timeAvailableBeforeTurn_;
}
return timePlayedBeforeTurn_;
}
+
+void ChessClock::setTimeAvailable(int msecs)
+{
+ timeAvailableBeforeTurn_ = msecs;
+}
+
void ChessClock::updateClock()
{
// Check loser
@return Time played in msecs */
virtual int getTimePlayed() const;
+ /*! Set time available
+
+ @param msecs Time available in msecs */
+ void setTimeAvailable(int msecs);
+
signals:
void timeOutLoser();
+ void endTurn();
public slots:
timeAverage = 0;
else
timeAverage = getTimePlayed() / getTurn();
- timeAverageLabel_->setText( tr("Average %1 per turn").arg( timeString( timeAverage ) ) );
+ timeAverageLabel_->setText( tr("Avg %1").arg( timeString( timeAverage ) ) );
turnLabel_->setText( tr("Turn %1").arg(getTurn()));
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
+ a.setApplicationName( a.tr("Chess Clock","Application name") );
+ a.setApplicationVersion("0.1.0");
+
ChessClockWindow w;
+
#if defined(Q_WS_S60)
w.showMaximized();
#else
+++ /dev/null
-
-/**************************************************************************
-
- Chess Clock
-
- Copyright (c) Arto Hyvättinen 2010
-
- This file is part of Chess Clock software.
-
- Chess Clock is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Chess Clock is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
-
-**************************************************************************/