49d5f816ca21a530566f457d78cea0acc6106efe
[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 accedd 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
15 @author Heli Hyvättinen
16 @date 2011-09-28
17 @version 1.9.1
18
19   */
20
21 class Settings : public QObject
22 {
23     Q_OBJECT
24 public:
25     explicit Settings(QObject *parent = 0);
26     /*!
27    Returns turns per addition from settings.
28    @param timeControl Time control for which the setting is queried
29    @param isWhite true for white player, false for black
30    */
31     Q_INVOKABLE int getTurnsPerAddition(WrappedClocksWidget::TimeControlType timeControl, bool isWhite);
32
33     /*!
34    Returns intitial time (in milliseconds) from settings.
35    @param timeControl Time control for which the setting is queried
36    @param isWhite true for white player, false for black
37    */
38     Q_INVOKABLE int getInitialTime(WrappedClocksWidget::TimeControlType timeControl, bool isWhite);
39
40     /*!
41    Returns additional time (in milliseconds) from settings.
42    @param timeControl Time control for which the setting is queried
43    @param isWhite true for white player, false for black
44    */
45     Q_INVOKABLE int getAdditionalTime(WrappedClocksWidget::TimeControlType timeControl, bool isWhite);
46
47     /*!
48       Returns whether the equal times is set in the settings
49       @param timeControl Time control for which the setting is queried
50       */
51     Q_INVOKABLE bool isEqualTimes(WrappedClocksWidget::TimeControlType timeControl);
52
53
54
55 signals:
56
57 public slots:
58
59     /*!
60     Sets turns per addition in settings.
61    @param timeControl Time control for which the setting is set
62    @param isWhite true for white player, false for black
63    @param turns The value to be saved
64    */
65     void setTurnsPerAddition(WrappedClocksWidget::TimeControlType timeControl, bool isWhite, int turns);
66
67     /*!
68     Sets initial time in settings.
69    @param timeControl Time control for which the setting is set
70    @param isWhite true for white player, false for black
71    @param time The time to be saved, in milliseconds
72    */
73     void setInitialTime(WrappedClocksWidget::TimeControlType timeControl, bool isWhite, int time);
74
75     /*!
76     Sets additional time in settings.
77    @param timeControl Time control for which the setting is set
78    @param isWhite true for white player, false for black
79    @param time The time to be saved, in milliseconds
80    */
81
82     void setAdditionalTime(WrappedClocksWidget::TimeControlType timeControl, bool isWhite, int time);
83
84     /*! Sets the equal times setting
85       @param timeControl Time control for which the setting is set
86     */
87     void setEqualTimes(WrappedClocksWidget::TimeControlType timeControl,bool on);
88
89 protected:
90
91     QString getGroupName(WrappedClocksWidget::TimeControlType timeControl);
92
93 };
94
95 #endif // SETTINGS_H