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 
8 #ifdef QT_DEBUG
9  #include <QDebug>
10 #endif
11 
19 class BoxingSettings : public QSettings {
20  Q_OBJECT
21 
23  Q_PROPERTY(QString preset READ getPreset WRITE setPreset NOTIFY presetChanged)
24  Q_PROPERTY(QString presetName READ getPresetName NOTIFY presetChanged)
25  Q_PROPERTY(int rounds READ getRounds WRITE setRounds NOTIFY presetChanged)
26  Q_PROPERTY(int roundsMs READ getRoundMilliseconds WRITE setRoundMilliseconds NOTIFY presetChanged)
27  Q_PROPERTY(int restMs READ getRestMilliseconds WRITE setRestMilliseconds NOTIFY presetChanged)
34  const int DefaultRounds = 12;
35 
40  const int DefaultRoundMilliseconds = 3 * 60 * 1000;
45  const int DefaultRestMilliseconds = 60 * 1000;
46 
51  const QString DefaultPreset = "";
52 
57  const QString DefaultPresetName = "Default";
58 
59  public:
67  Q_INVOKABLE const QStringList presetsList();
68 
81  Q_INVOKABLE void savePreset(const QString &name, const int &rounds, const int &roundMilliseconds, const int &restMilliseconds);
82 
92  Q_INVOKABLE void deletePreset(const QString &name);
93 
95  BoxingSettings(const int &rounds, const int &roundMilliseconds, const int &restMilliseconds);
96 
102  inline int getRounds() { return this->mRounds; }
103 
109  inline int getRoundMilliseconds() { return this->mRoundMilliseconds; }
110 
116  inline int getRestMilliseconds() { return this->mRestMilliseconds; }
117 
123  inline QString getPreset() { return this->mPreset; }
124 
130  inline QString getPresetName() { return this->mPresetName; }
131 
138  inline void setRounds(const int &rounds) { mRounds = rounds; }
139 
146  inline void setRoundMilliseconds(const int &roundMilliseconds) { mRoundMilliseconds = roundMilliseconds; }
147 
154  inline void setRestMilliseconds(const int &restMilliseconds) { mRestMilliseconds = restMilliseconds; }
155 
162  void setPreset(const QString &preset);
163 
164  private:
165  int mRounds;
166  int mRoundMilliseconds;
167  int mRestMilliseconds;
168 
169  QString mPreset;
170  QString mPresetName;
171 
177  void loadPreset();
178 
184  void setDefaultPreset();
185 
192  inline const QString convertRichNameToGroup(const QString &richName) { return richName.toLower().simplified().replace(" ", ""); }
193 
194  signals:
195  void presetChanged();
196 };
197 
198 #endif // BOXINGSETTINGS_H
void setRestMilliseconds(const int &restMilliseconds)
Setter for milliseconds of rest.
Definition: boxingsettings.h:154
void setPreset(const QString &preset)
Setter for preset.
Definition: boxingsettings.cpp:25
QString getPreset()
Definition: boxingsettings.h:123
Q_INVOKABLE const QStringList presetsList()
Definition: boxingsettings.cpp:84
void setRounds(const int &rounds)
Setter for number of rounds.
Definition: boxingsettings.h:138
Q_INVOKABLE void savePreset(const QString &name, const int &rounds, const int &roundMilliseconds, const int &restMilliseconds)
Save or override settings about specific preset.
Definition: boxingsettings.cpp:59
void presetChanged()
int getRestMilliseconds()
Definition: boxingsettings.h:116
int getRoundMilliseconds()
Definition: boxingsettings.h:109
Q_INVOKABLE void deletePreset(const QString &name)
Delete a specified preset.
Definition: boxingsettings.cpp:72
QString getPresetName()
Definition: boxingsettings.h:130
BoxingSettings()
Definition: boxingsettings.cpp:5
int getRounds()
Definition: boxingsettings.h:102
Handle settings about timer. Can save, load and delete a specific preset.
Definition: boxingsettings.h:19
void setRoundMilliseconds(const int &roundMilliseconds)
Setter for duration of round (in milliseconds)
Definition: boxingsettings.h:146