Boxing Timer  1.0
boxingtimer.h
Go to the documentation of this file.
1 #ifndef BOXINGTIMER_H
2 #define BOXINGTIMER_H
3 
4 #include <QTimer>
5 #include <QString>
6 #include <QStringList>
7 
8 #ifdef QT_DEBUG
9  #include <QDebug>
10 #endif
11 
16 class BoxingSettings;
17 
26 class BoxingTimer : public QTimer {
27  Q_OBJECT
28  Q_ENUMS(Status)
29 
30 
32  Q_PROPERTY(QString roundsToString READ roundsToString NOTIFY roundsToStringChanged)
33  Q_PROPERTY(Status status READ getStatus WRITE setStatus NOTIFY statusChanged)
34  Q_PROPERTY(bool isActive READ isActive NOTIFY activeChanged)
35  Q_PROPERTY(QString preset READ getPreset NOTIFY presetChanged)
38  public:
39 
47  Q_INVOKABLE void restore();
48 
56  Q_INVOKABLE void loadPreset(const QString &preset);
57 
64  explicit BoxingTimer();
65 
73  const QString roundsToString();
74 
82  const QString remainingTimeToString();
83 
90  enum class Status : short {
91  Default = 0,
92  Start,
93  Rest,
94  Pause,
95  Reset,
96  Stop
97  };
98 
104  Status getStatus() { return this->mStatus; }
105 
112  void setStatus(const Status &status);
113 
119  const QString getPreset();
120 
121  public slots:
127  void applyStatus();
128 
135 
136  protected:
142  void stop();
143 
149  void start(const int &milliseconds);
150 
151  private:
152  int mRound;
153 
154  int mRoundsMilliseconds;
155  int mRemainingMilliseconds;
156 
157  void setRemainingMilliseconds(const int &milliseconds);
158  void setRound(const int &round);
159 
160  Status mStatus;
161  Status mOldStatus;
162 
163  BoxingSettings *settings;
164 
170  void nextRound();
171 
172  signals:
174  void roundsToStringChanged();
175 
176  void statusChanged();
177  void presetChanged();
178  void activeChanged();
179 };
180 
181 Q_DECLARE_METATYPE(BoxingTimer::Status)
182 
183 #endif // BOXINGTIMER_H
BoxingTimer()
Default constructor.
Definition: boxingtimer.cpp:8
Q_INVOKABLE void loadPreset(const QString &preset)
Load the preset to change settings of timer.
Definition: boxingtimer.cpp:146
const QString remainingTimeToString()
Convert remaining milliseconds in human readable time.
Definition: boxingtimer.cpp:111
Q_INVOKABLE void restore()
Start or restore the timer.
Definition: boxingtimer.cpp:125
void stop()
Override of stop function to emit statusChanged() signal.
Definition: boxingtimer.cpp:48
const QString roundsToString()
Convert round and total rounds for view.
Definition: boxingtimer.cpp:133
Status
Define the status of the timer Some statuses are not saved, they are used to activate something...
Definition: boxingtimer.h:90
void start(const int &milliseconds)
Override of start function to emit statusChanged() signal.
Definition: boxingtimer.cpp:54
void setStatus(const Status &status)
Definition: boxingtimer.cpp:38
void activeChanged()
void roundsToStringChanged()
void statusChanged()
Status getStatus()
Definition: boxingtimer.h:104
void applyStatus()
Apply status and exec relative functions.
Definition: boxingtimer.cpp:60
void presetChanged()
void updateRemainingMilliseconds()
Switch milliseconds from round to rest and back.
Definition: boxingtimer.cpp:95
Handle settings about timer. Can save, load and delete a specific preset.
Definition: boxingsettings.h:19
Boxing timer class.
Definition: boxingtimer.h:26
void remainingTimeToStringChanged()
const QString getPreset()
Definition: boxingtimer.cpp:22