Boxing Timer  0.1a
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 QSound;
17 class BoxingSettings;
18 
27 class BoxingTimer : public QTimer {
28  Q_OBJECT
29  Q_ENUMS(Status)
30 
31 
33  Q_PROPERTY(QString roundsToString READ roundsToString NOTIFY roundsToStringChanged)
34  Q_PROPERTY(Status status READ getStatus WRITE setStatus NOTIFY statusChanged)
35  Q_PROPERTY(bool isActive READ isActive NOTIFY activeChanged)
36  Q_PROPERTY(QString preset READ getPreset NOTIFY presetChanged)
39  public:
40 
48  Q_INVOKABLE void restore();
49 
57  Q_INVOKABLE void loadPreset(const QString &preset);
58 
65  explicit BoxingTimer();
66 
74  const QString roundsToString();
75 
83  const QString remainingTimeToString();
84 
91  enum class Status : short {
92  Default = 0,
93  Start,
94  Rest,
95  Pause,
96  Reset,
97  Stop
98  };
99 
105  Status getStatus() { return this->mStatus; }
106 
113  void setStatus(const Status &status);
114 
120  const QString getPreset();
121 
122  public slots:
128  void applyStatus();
129 
136 
137  protected:
143  void stop();
144 
150  void start(const int &milliseconds);
151 
152  private:
153  int mRound;
154 
155  int mRoundsMilliseconds;
156  int mRemainingMilliseconds;
157 
158  void setRemainingMilliseconds(const int &milliseconds);
159  void setRound(const int &round);
160 
161  QSound *playBell;
162  QSound *restBell;
163  QSound *stopBell;
164 
170  void songsBell();
171 
172  Status mStatus;
173  Status mOldStatus;
174 
175  BoxingSettings *settings;
176 
182  void nextRound();
183 
184  signals:
186  void roundsToStringChanged();
187 
188  void statusChanged();
189  void presetChanged();
190  void activeChanged();
191 };
192 
193 Q_DECLARE_METATYPE(BoxingTimer::Status)
194 
195 #endif // BOXINGTIMER_H
BoxingTimer()
Default constructor.
Definition: boxingtimer.cpp:9
Q_INVOKABLE void loadPreset(const QString &preset)
Load the preset to change settings of timer.
Definition: boxingtimer.cpp:154
const QString remainingTimeToString()
Convert remaining milliseconds in human readable time.
Definition: boxingtimer.cpp:119
Q_INVOKABLE void restore()
Start or restore the timer.
Definition: boxingtimer.cpp:133
void stop()
Override of stop function to emit statusChanged() signal.
Definition: boxingtimer.cpp:52
const QString roundsToString()
Convert round and total rounds for view.
Definition: boxingtimer.cpp:141
Status
Define the status of the timer Some statuses are not saved, they are used to activate something...
Definition: boxingtimer.h:91
void start(const int &milliseconds)
Override of start function to emit statusChanged() signal.
Definition: boxingtimer.cpp:58
void setStatus(const Status &status)
Definition: boxingtimer.cpp:42
void activeChanged()
void roundsToStringChanged()
void statusChanged()
Status getStatus()
Definition: boxingtimer.h:105
void applyStatus()
Apply status and exec relative functions.
Definition: boxingtimer.cpp:64
void presetChanged()
void updateRemainingMilliseconds()
Switch milliseconds from round to rest and back.
Definition: boxingtimer.cpp:101
Handle settings about timer. Can save, load and delete a specific preset.
Definition: boxingsettings.h:19
Boxing timer class.
Definition: boxingtimer.h:27
void remainingTimeToStringChanged()
const QString getPreset()
Definition: boxingtimer.cpp:26