Time control base classes
[chessclock] / classes / timecontrol / basicdialog.h
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 #ifndef BASICDIALOG_H
23 #define BASICDIALOG_H
24
25 #include <QDialog>
26 #include <QString>
27 #include <QTime>
28
29 class QTimeEdit;
30 class QSpinBox;
31 class QCheckBox;
32 class QLabel;
33
34 /*! Basic dialog for Time Control settings
35
36   @author Arto Hyvättinen
37   @date 2010-08-16
38
39   Basic dialog setting up clock.
40   Time control can use this dialog.
41   Using disableAddition(), disablePerTurns() or disableUnEquals()
42   it is possible to customize dialog.
43
44   All the widgets are public for customization.
45   */
46
47 class BasicDialog : public QDialog
48 {
49     Q_OBJECT
50 public:
51     /*! Constructor
52
53       @param timeControlName Name of time controller, will be window title */
54     BasicDialog(QString timeContolName, QWidget *parent = 0);
55
56     void disableAddition();
57     void disablePerTurns();
58     void disableUnEquals();
59
60     int getWhiteInitial();
61     int getBlackInitial();
62     int getWhiteAddition();
63     int getBlackAddition();
64     int getWhitePerTurns();
65     int getBlackPerTurns();
66     /*! Store values to settings */
67     void store();
68     /*! Load values from settings, or init to initial values */
69     void init(QTime whiteInitial=QTime(1,30),
70               QTime blackInitial=QTime(1,30),
71               QTime whiteAddition=QTime(0,0,30),
72               QTime blackAddition=QTime(0,0,30),
73               int whitePerTurns = 1,
74               int blackPerTurns = 1);
75 signals:
76
77 public slots:
78
79 protected:
80     static QTimeEdit* initTimeEdit();
81     static int toMsecs(QTimeEdit* timeEdit);
82
83 public:
84     QTimeEdit *whiteInitial_, *blackInitial_;
85     QTimeEdit *whiteAddition_, *blackAddition_;
86     QSpinBox *whiteTurns_, *blackTurns_;
87     QCheckBox *equals_;
88
89     QLabel *initialLabel_, *additionLabel_, *perTurnLabel_, *equalsLabel_;
90     QLabel *whiteLabel_, *blackLabel_;
91
92 protected:
93     QString timeControlName_;
94
95
96 };
97
98 #endif // BASICDIALOG_H