Boxing Timer  0.1a
boxingsettings.h
Go to the documentation of this file.
1 #ifndef BOXINGSETTINGS_H
2 #define BOXINGSETTINGS_H
3 
4 #include <QString>
5 #include <QStringList>
6 #include <QSettings>
7 #include <QList>
8 
9 #ifdef QT_DEBUG
10  #include <QDebug>
11 #endif
12 
20 class BoxingSettings : public QSettings {
21  Q_OBJECT
22 
24  Q_PROPERTY(QString preset READ getPreset WRITE setPreset NOTIFY presetChanged)
25  Q_PROPERTY(QString presetName READ getPresetName NOTIFY presetChanged)
26  Q_PROPERTY(int rounds READ getRounds WRITE setRounds NOTIFY presetChanged)
27  Q_PROPERTY(int roundsMs READ getRoundMilliseconds WRITE setRoundMilliseconds NOTIFY presetChanged)
28  Q_PROPERTY(int restMs READ getRestMilliseconds WRITE setRestMilliseconds NOTIFY presetChanged)
29  Q_PROPERTY(QList<int> innerTimers READ getInnerTimers NOTIFY presetChanged)
36  const int DefaultRounds = 12;
37 
42  const int DefaultRoundMilliseconds = 3 * 60 * 1000;
47  const int DefaultRestMilliseconds = 60 * 1000;
48 
53  const QString DefaultPreset = "";
54 
59  const QString DefaultPresetName = "Default";
60 
61  public:
69  Q_INVOKABLE const QStringList presetsList();
70 
83  Q_INVOKABLE void savePreset(const QString &name, const int &rounds, const int &roundMilliseconds, const int &restMilliseconds, const QList<int> &innerTimers);
84 
94  Q_INVOKABLE void deletePreset(const QString &name);
95 
101  Q_INVOKABLE int getInnerTimer(const int &index);
102 
103  BoxingSettings();
104  BoxingSettings(const int &rounds, const int &roundMilliseconds, const int &restMilliseconds);
105 
111  inline int getRounds() { return this->mRounds; }
112 
118  inline int getRoundMilliseconds() { return this->mRoundMilliseconds; }
119 
125  inline int getRestMilliseconds() { return this->mRestMilliseconds; }
126 
132  inline QList<int> getInnerTimers() { return this->mInnerTimers; }
133 
139  inline QString getPreset() { return this->mPreset; }
140 
146  inline QString getPresetName() { return this->mPresetName; }
147 
154  inline void setRounds(const int &rounds) { mRounds = rounds; }
155 
162  inline void setRoundMilliseconds(const int &roundMilliseconds) { mRoundMilliseconds = roundMilliseconds; }
163 
170  inline void setRestMilliseconds(const int &restMilliseconds) { mRestMilliseconds = restMilliseconds; }
171 
178  void setPreset(const QString &preset);
179 
180  private:
181  int mRounds;
182  int mRoundMilliseconds;
183  int mRestMilliseconds;
184 
185  QList<int> mInnerTimers;
186 
187  QString mPreset;
188  QString mPresetName;
189 
195  void loadPreset();
196 
202  void setDefaultPreset();
203 
210  inline const QString convertRichNameToGroup(const QString &richName) { return richName.toLower().simplified().replace(" ", ""); }
211 
212  signals:
213  void presetChanged();
214 };
215 
216 #endif // BOXINGSETTINGS_H
void setRestMilliseconds(const int &restMilliseconds)
Setter for milliseconds of rest.
Definition: boxingsettings.h:170
void setPreset(const QString &preset)
Setter for preset.
Definition: boxingsettings.cpp:26
QString getPreset()
Definition: boxingsettings.h:139
Q_INVOKABLE const QStringList presetsList()
Definition: boxingsettings.cpp:90
QList< int > getInnerTimers()
gerInnerTimers()
Definition: boxingsettings.h:132
void setRounds(const int &rounds)
Setter for number of rounds.
Definition: boxingsettings.h:154
void presetChanged()
int getRestMilliseconds()
Definition: boxingsettings.h:125
int getRoundMilliseconds()
Definition: boxingsettings.h:118
Q_INVOKABLE void deletePreset(const QString &name)
Delete a specified preset.
Definition: boxingsettings.cpp:78
QString getPresetName()
Definition: boxingsettings.h:146
Q_INVOKABLE int getInnerTimer(const int &index)
getInnerTimer(const int &index)
Definition: boxingsettings.cpp:100
Q_INVOKABLE void savePreset(const QString &name, const int &rounds, const int &roundMilliseconds, const int &restMilliseconds, const QList< int > &innerTimers)
Save or override settings about specific preset.
Definition: boxingsettings.cpp:64
BoxingSettings()
Definition: boxingsettings.cpp:6
int getRounds()
Definition: boxingsettings.h:111
Handle settings about timer. Can save, load and delete a specific preset.
Definition: boxingsettings.h:20
void setRoundMilliseconds(const int &roundMilliseconds)
Setter for duration of round (in milliseconds)
Definition: boxingsettings.h:162