bfefb4f24022ff7d9f59b65e3f69535094e3ca47
[chessclock] / classes / settings.h
1 #ifndef SETTINGS_H
2 #define SETTINGS_H
3
4 #include <QObject>
5 #include "classes/wrappedclockswidget.h"
6
7
8 /*! A class that gives access to settings
9
10 Used to save the last used dialog settings.
11 Uses QSettings internally.
12 Note: not compatible with the settings used in the Maemo versions.
13 The group names are the same, but the times are saved as ints (milliseconds) rather than QTimes.
14 Time Control is passed as int due to QML problem, but *must* be a valid
15 WrappedClocksWidget::TimeControlType enum to work. (All other values are interpreted as "Normal Clock"
16
17 @author Heli Hyvättinen
18 @date 2011-10-03
19 @version 1.9.1
20
21   */
22
23 class Settings : public QObject
24 {
25     Q_OBJECT
26 public:
27     explicit Settings(QObject *parent = 0);
28     /*!
29    Returns turns per addition from settings.
30    @param timeControl Time control for which the setting is queried
31    @param isWhite true for white player, false for black
32    */
33     Q_INVOKABLE int getTurnsPerAddition(int timeControl, bool isWhite);
34
35     /*!
36    Returns intitial time (in milliseconds) from settings.
37    @param timeControl Time control for which the setting is queried
38    @param isWhite true for white player, false for black
39    */
40     Q_INVOKABLE int getInitialTime(int timeControl, bool isWhite);
41
42     /*!
43    Returns additional time (in milliseconds) from settings.
44    @param timeControl Time control for which the setting is queried
45    @param isWhite true for white player, false for black
46    */
47     Q_INVOKABLE int getAdditionalTime(int timeControl, bool isWhite);
48
49     /*!
50       Returns whether the equal times is set in the settings
51       @param timeControl Time control for which the setting is queried
52       */
53     Q_INVOKABLE bool isEqualTimes(int timeControl);
54
55
56
57 signals:
58
59 public slots:
60
61     /*!
62     Sets turns per addition in settings.
63    @param timeControl Time control for which the setting is set
64    @param isWhite true for white player, false for black
65    @param turns The value to be saved
66    */
67     void setTurnsPerAddition(int timeControl, bool isWhite, int turns);
68
69     /*!
70     Sets initial time in settings.
71    @param timeControl Time control for which the setting is set
72    @param isWhite true for white player, false for black
73    @param time The time to be saved, in milliseconds
74    */
75     void setInitialTime(int timeControl, bool isWhite, int time);
76
77     /*!
78     Sets additional time in settings.
79    @param timeControl Time control for which the setting is set
80    @param isWhite true for white player, false for black
81    @param time The time to be saved, in milliseconds
82    */
83
84     void setAdditionalTime(int timeControl, bool isWhite, int time);
85
86     /*! Sets the equal times setting
87       @param timeControl Time control for which the setting is set
88     */
89     void setEqualTimes(int timeControl,bool on);
90
91 protected:
92
93     QString getGroupName(int timeControl);
94
95 };
96
97 #endif // SETTINGS_H