X-Git-Url: http://git.maemo.org/git/?p=chessclock;a=blobdiff_plain;f=classes%2Fclockswidget.cpp;fp=classes%2Fclockswidget.cpp;h=ed1352bb5b702ce75a6ac6ea9e1f5a6016278eb0;hp=0000000000000000000000000000000000000000;hb=ca6853daf22068621981987588b9d670f03a5264;hpb=a08f83a286b96562233e9753c9fb189cb1126fc0 diff --git a/classes/clockswidget.cpp b/classes/clockswidget.cpp new file mode 100644 index 0000000..ed1352b --- /dev/null +++ b/classes/clockswidget.cpp @@ -0,0 +1,105 @@ + /************************************************************************** + + 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. + + +**************************************************************************/ + +#include "clockswidget.h" +#include "chessclock.h" +#include "welcomescreenwidget.h" + +#include +#include +#include +#include +#include +#include + + +ClocksWidget::ClocksWidget(QWidget *parent) : + QWidget(parent) +{ + white_ = 0; + black_ = 0; + status_ = NoClocks; + + // Make layout for clocks + QHBoxLayout* clockLayout_ = new QHBoxLayout; + + // Pause information label + pauseLabel_ = new QLabel( tr("Paused. Touch to continue.")); + pauseLabel_->setFont( QFont("Helvetica",25)); + pauseLabel_->setAlignment( Qt::AlignCenter); + pauseLabel_->setVisible( false ); + + // Welcome label for first touch + welcomeLabel_ = new QLabel( tr("Welcome! Please touch to start game.
" + "Then touch to end turn.
")); + welcomeLabel_->setFont( QFont("Helvetica",25)); + welcomeLabel_->setAlignment( Qt::AlignCenter); + welcomeLabel_->setVisible( false ); + + // Welcome screen if no clocks set + welcomeScreen_ = new WelcomeScreenWidget(this); + + // Put all in layout + QVBoxLayout* mainLayout = new QVBoxLayout; + mainLayout->addLayout(clockLayout_); + mainLayout->addWidget(pauseLabel_); + mainLayout->addWidget(welcomeLabel_); + mainLayout->addWidget(welcomeScreen_); + + setLayout( mainLayout); + +} + + + +void ClocksWidget::setClocks(ChessClock *white, ChessClock *black) +{ + // Remove old clocks + if( white_ ) + { + clockLayout_->removeWidget( white_ ); + delete white_; + } + if( black_ ) + { + clockLayout_->removeWidget( black_ ); + delete black_; + } + + // Set up new ones + white_ = white; + black_ = black; + + clockLayout_->addWidget(white_); + clockLayout_->addWidget( black_ ); + + // First paint + white_->repaintClock(); + black_->repaintClock(); + + // Welcome status for first touch + welcomeLabel_->setVisible(true); + status_ = Welcome; + + +} + +int const ClocksWidget::CLICKDELAY;