00001 /************************************************************************** 00002 00003 Chess Clock 00004 00005 Copyright (c) Arto Hyvättinen 2010 00006 00007 This file is part of Chess Clock software. 00008 00009 Chess Clock is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 Chess Clock is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 00020 **************************************************************************/ 00021 00022 #include "delaytimecontrol.h" 00023 #include "delayclock.h" 00024 #include "../clockswidget.h" 00025 #include "basicdialog.h" 00026 00027 #include <QApplication> 00028 #include <QLabel> 00029 00030 DelayTimeControl::DelayTimeControl() 00031 { 00032 } 00033 00034 QString DelayTimeControl::getName() 00035 { 00036 return qApp->translate("Delay","Delay"); 00037 } 00038 00039 QIcon DelayTimeControl::getIcon() 00040 { 00041 return QIcon(":/rc/pic/pausebefore.png"); 00042 } 00043 00044 QString DelayTimeControl::getDescription() 00045 { 00046 return qApp->translate("Delay","The clock waits for the delay period before starting"); 00047 } 00048 00049 ClocksWidget* DelayTimeControl::initGame(bool useLastSettings) 00050 { 00051 BasicDialog dialog(getName()); 00052 dialog.disablePerTurns(); 00053 dialog.additionLabel_->setText(qApp->translate("Delay","Delay time")); 00054 dialog.init(); 00055 00056 if( useLastSettings || dialog.exec() == QDialog::Accepted) 00057 { 00058 dialog.store(); 00059 DelayClock* white = new DelayClock( true, dialog.getWhiteAddition()); 00060 white->setTimeAvailable(dialog.getWhiteInitial()); 00061 00062 DelayClock* black = new DelayClock( false, dialog.getBlackAddition()); 00063 black->setTimeAvailable( dialog.getBlackInitial()); 00064 00065 return( new ClocksWidget(white,black)); 00066 00067 } 00068 else 00069 return 0; 00070 }