1 /**************************************************************************
5 This file is part of Chess Clock software.
7 (This file) Copyright (c) Heli Hyvättinen 2011
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.
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.
20 **************************************************************************/
26 #include "classes/wrappedclockswidget.h"
29 /*! A class that gives access to settings
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")
37 @author Heli Hyvättinen
43 class Settings : public QObject
47 explicit Settings(QObject *parent = 0);
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
53 Q_INVOKABLE int getTurnsPerAddition(int timeControl, bool isWhite);
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
60 Q_INVOKABLE QTime getInitialTime(int timeControl, bool isWhite);
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
67 Q_INVOKABLE QTime getAdditionalTime(int timeControl, bool isWhite);
70 Returns whether the equal times is set in the settings
71 @param timeControl Time control for which the setting is queried
73 Q_INVOKABLE bool isEqualTimes(int timeControl);
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
87 void setTurnsPerAddition(int timeControl, bool isWhite, int turns);
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
95 void setInitialTime(int timeControl, bool isWhite, QTime time);
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
104 void setInitialTime(int timeControl, bool isWhite, int hours, int minutes, int seconds);
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
112 void setAdditionalTime(int timeControl, bool isWhite, QTime time);
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
121 void setAdditionalTime(int timeControl, bool isWhite, int hours, int minutes, int seconds);
124 /*! Sets the equal times setting
125 @param timeControl Time control for which the setting is set
127 void setEqualTimes(int timeControl,bool on);
134 QString getGroupName(int timeControl);