Corrected version number in .pro for release in OBS
[chessclock] / classes / settings.h
1 /**************************************************************************
2
3    Chess Clock
4
5    This file is part of Chess Clock software.
6
7    (This file) Copyright (c) Heli Hyvättinen 2011
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 SETTINGS_H
23 #define SETTINGS_H
24
25 #include <QObject>
26 #include "classes/wrappedclockswidget.h"
27
28
29 /*! A class that gives access to settings
30
31 Used to save the last used dialog settings.
32 Uses QSettings internally.
33 Compatible with the settings used in the Maemo versions.
34 Time Control is passed as int due to a QML problem, but *must* be a valid WrappedClocksWidget::TimeControlType enum to work.
35 (All other values are interpreted as "Normal Clock")
36
37 @author Heli Hyvättinen
38 @date 2011-10-04
39 @version 1.9.1
40
41   */
42
43 class Settings : public QObject
44 {
45     Q_OBJECT
46 public:
47     explicit Settings(QObject *parent = 0);
48     /*!
49    Returns turns per addition from settings.
50    @param timeControl Time control for which the setting is queried
51    @param isWhite true for white player, false for black
52    */
53     Q_INVOKABLE int getTurnsPerAddition(int timeControl, bool isWhite);
54
55     /*!
56    Returns intitial time (in milliseconds) from settings.
57    @param timeControl Time control for which the setting is queried
58    @param isWhite true for white player, false for black
59    */
60     Q_INVOKABLE QTime getInitialTime(int timeControl, bool isWhite);
61
62     /*!
63    Returns additional time (in milliseconds) from settings.
64    @param timeControl Time control for which the setting is queried
65    @param isWhite true for white player, false for black
66    */
67     Q_INVOKABLE QTime getAdditionalTime(int timeControl, bool isWhite);
68
69     /*!
70       Returns whether the equal times is set in the settings
71       @param timeControl Time control for which the setting is queried
72       */
73     Q_INVOKABLE bool isEqualTimes(int timeControl);
74
75
76
77 signals:
78
79 public slots:
80
81     /*!
82     Sets turns per addition in settings.
83    @param timeControl Time control for which the setting is set
84    @param isWhite true for white player, false for black
85    @param turns The value to be saved
86    */
87     void setTurnsPerAddition(int timeControl, bool isWhite, int turns);
88
89       /*!
90     Sets initial time in settings.
91    @param timeControl Time control for which the setting is set
92    @param isWhite true for white player, false for black
93    @param time The time to be saved
94    */
95     void setInitialTime(int timeControl, bool isWhite, QTime time);
96
97     /*! Sets initial time in settings
98    @param timeControl Time control for which the setting is set
99    @param isWhite true for white player, false for black
100    @param hours Hour component of the time to be saved
101    @param minutes Minutes component of the time to be saved
102    @param seconds Seconds component of the time to be saved
103    */
104     void setInitialTime(int timeControl, bool isWhite, int hours, int minutes, int seconds);
105
106     /*!
107     Sets additional time in settings.
108    @param timeControl Time control for which the setting is set
109    @param isWhite true for white player, false for black
110    @param time The time to be saved
111    */
112     void setAdditionalTime(int timeControl, bool isWhite, QTime time);
113
114     /*! Sets additional time in settings
115    @param timeControl Time control for which the setting is set
116    @param isWhite true for white player, false for black
117    @param hours Hour component of the time to be saved
118    @param minutes Minutes component of the time to be saved
119    @param seconds Seconds component of the time to be saved
120    */
121    void setAdditionalTime(int timeControl, bool isWhite, int hours, int minutes, int seconds);
122
123
124     /*! Sets the equal times setting
125       @param timeControl Time control for which the setting is set
126     */
127     void setEqualTimes(int timeControl,bool on);
128
129
130
131
132 protected:
133
134     QString getGroupName(int timeControl);
135
136 };
137
138 #endif // SETTINGS_H