boxingtimer.h
Go to the documentation of this file.
#ifndef BOXINGTIMER_H
#define BOXINGTIMER_H
#include <QTimer>
#include <QString>
#include <QStringList>
#ifdef QT_DEBUG
#include <QDebug>
#endif
class QSound;
class BoxingSettings;
class BoxingTimer : public QTimer {
Q_OBJECT
Q_ENUMS(Status)
Q_PROPERTY(QString remainingTimeToString READ remainingTimeToString NOTIFY remainingTimeToStringChanged)
Q_PROPERTY(QString roundsToString READ roundsToString NOTIFY roundsToStringChanged)
Q_PROPERTY(Status status READ getStatus WRITE setStatus NOTIFY statusChanged)
Q_PROPERTY(bool isActive READ isActive NOTIFY activeChanged)
Q_PROPERTY(QString preset READ getPreset NOTIFY presetChanged)
public:
Q_INVOKABLE void restore();
Q_INVOKABLE void loadPreset(const QString &preset);
explicit BoxingTimer();
const QString roundsToString();
const QString remainingTimeToString();
enum class Status : short {
Default = 0,
Start,
Rest,
Pause,
Reset,
Stop
};
Status getStatus() { return this->mStatus; }
void setStatus(const Status &status);
const QString getPreset();
public slots:
void applyStatus();
void updateRemainingMilliseconds();
protected:
void stop();
void start(const int &milliseconds);
private:
int mRound;
int mRoundsMilliseconds;
int mRemainingMilliseconds;
int mInnerTime;
int mNumberOfInnerTimers;
int mInnerRemainingMilliseconds;
void setRemainingMilliseconds(const int &milliseconds);
void setRound(const int &round);
QSound *playBell;
QSound *restBell;
QSound *stopBell;
QSound *innerBell;
void songsBell();
Status mStatus;
Status mOldStatus;
BoxingSettings *settings;
void nextRound();
void updateInnerRemainingMilliseconds();
void setInnerTimers();
signals:
void remainingTimeToStringChanged();
void roundsToStringChanged();
void statusChanged();
void presetChanged();
void activeChanged();
};
Q_DECLARE_METATYPE(BoxingTimer::Status)
#endif // BOXINGTIMER_H
BoxingTimer::Status::Start
BoxingTimer::BoxingTimer
BoxingTimer()
Default constructor.
Definition: boxingtimer.cpp:9
BoxingTimer::Status::Stop
BoxingTimer::loadPreset
Q_INVOKABLE void loadPreset(const QString &preset)
Load the preset to change settings of timer.
Definition: boxingtimer.cpp:190
BoxingTimer::Status::Default
BoxingTimer::remainingTimeToString
const QString remainingTimeToString()
Convert remaining milliseconds in human readable time.
Definition: boxingtimer.cpp:155
BoxingTimer::restore
Q_INVOKABLE void restore()
Start or restore the timer.
Definition: boxingtimer.cpp:169
BoxingTimer::stop
void stop()
Override of stop function to emit statusChanged() signal.
Definition: boxingtimer.cpp:56
BoxingTimer::roundsToString
const QString roundsToString()
Convert round and total rounds for view.
Definition: boxingtimer.cpp:177
BoxingTimer::Status
Status
Define the status of the timer Some statuses are not saved, they are used to activate something...
Definition: boxingtimer.h:91
BoxingTimer::start
void start(const int &milliseconds)
Override of start function to emit statusChanged() signal.
Definition: boxingtimer.cpp:62
BoxingTimer::setStatus
void setStatus(const Status &status)
Definition: boxingtimer.cpp:46
BoxingTimer::activeChanged
void activeChanged()
BoxingTimer::roundsToStringChanged
void roundsToStringChanged()
BoxingTimer::statusChanged
void statusChanged()
BoxingTimer::getStatus
Status getStatus()
Definition: boxingtimer.h:105
BoxingTimer::applyStatus
void applyStatus()
Apply status and exec relative functions.
Definition: boxingtimer.cpp:68
BoxingTimer::presetChanged
void presetChanged()
BoxingTimer::updateRemainingMilliseconds
void updateRemainingMilliseconds()
Switch milliseconds from round to rest and back.
Definition: boxingtimer.cpp:107
BoxingSettings
Handle settings about timer. Can save, load and delete a specific preset.
Definition: boxingsettings.h:20
BoxingTimer::Status::Pause
BoxingTimer
Boxing timer class.
Definition: boxingtimer.h:27
BoxingTimer::remainingTimeToStringChanged
void remainingTimeToStringChanged()
BoxingTimer::getPreset
const QString getPreset()
Definition: boxingtimer.cpp:30
BoxingTimer::Status::Reset
BoxingTimer::Status::Rest