d5918a8e2d21df29aa49c6bdf0ce4707e1e4ebb8
[chessclock] / classes / timecontrol / notimecontrol.cpp
1  /**************************************************************************
2
3     Chess Clock
4
5     Copyright (c) Arto Hyvättinen 2010
6
7     This file is part of Chess Clock software.
8
9     Chess Clock is free software: you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation, either version 3 of the License, or
12     (at your option) any later version.
13
14     Chess Clock is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18
19
20 **************************************************************************/
21
22 #include "notimecontrol.h"
23
24 #include "../chessclock.h"
25 #include "basicdialog.h"
26 #include "../chessclockwidget.h"
27 #include "../clockswidget.h"
28
29 #include <QApplication>
30
31 NoTimeControl::NoTimeControl()
32 {
33 }
34
35
36 QString NoTimeControl::getDescription()
37 {
38     return qApp->translate("NoneTimeControl","Never add time.");
39 }
40
41 ClocksWidget* NoTimeControl::initGame(bool useLastSettings)
42 {
43     BasicDialog dialog(getName());
44
45     dialog.disableAddition();
46     dialog.init();
47
48     if( useLastSettings || dialog.exec() == QDialog::Accepted)
49     {
50         dialog.store();
51         ChessClockWidget* white = new ChessClockWidget(true);
52         white->setTimeAvailable(dialog.getWhiteInitial());
53
54         ChessClockWidget* black = new ChessClockWidget(false);
55         black->setTimeAvailable( dialog.getBlackInitial());
56
57         return( new ClocksWidget(white,black));
58
59     }
60     else
61         return 0;
62 }