boxingsettings.h
Go to the documentation of this file.
#ifndef BOXINGSETTINGS_H
#define BOXINGSETTINGS_H
#include <QString>
#include <QStringList>
#include <QSettings>
#include <QList>
#ifdef QT_DEBUG
#include <QDebug>
#endif
class BoxingSettings : public QSettings {
Q_OBJECT
Q_PROPERTY(QString preset READ getPreset WRITE setPreset NOTIFY presetChanged)
Q_PROPERTY(QString presetName READ getPresetName NOTIFY presetChanged)
Q_PROPERTY(int rounds READ getRounds WRITE setRounds NOTIFY presetChanged)
Q_PROPERTY(int roundsMs READ getRoundMilliseconds WRITE setRoundMilliseconds NOTIFY presetChanged)
Q_PROPERTY(int restMs READ getRestMilliseconds WRITE setRestMilliseconds NOTIFY presetChanged)
Q_PROPERTY(QList<int> innerTimers READ getInnerTimers NOTIFY presetChanged)
const int DefaultRounds = 12;
const int DefaultRoundMilliseconds = 3 * 60 * 1000;
const int DefaultRestMilliseconds = 60 * 1000;
const QString DefaultPreset = "";
const QString DefaultPresetName = "Default";
public:
Q_INVOKABLE const QStringList presetsList();
Q_INVOKABLE void savePreset(const QString &name, const int &rounds, const int &roundMilliseconds, const int &restMilliseconds, const QList<int> &innerTimers);
Q_INVOKABLE void deletePreset(const QString &name);
Q_INVOKABLE int getInnerTimer(const int &index);
BoxingSettings();
BoxingSettings(const int &rounds, const int &roundMilliseconds, const int &restMilliseconds);
inline int getRounds() { return this->mRounds; }
inline int getRoundMilliseconds() { return this->mRoundMilliseconds; }
inline int getRestMilliseconds() { return this->mRestMilliseconds; }
inline QList<int> getInnerTimers() { return this->mInnerTimers; }
inline QString getPreset() { return this->mPreset; }
inline QString getPresetName() { return this->mPresetName; }
inline void setRounds(const int &rounds) { mRounds = rounds; }
inline void setRoundMilliseconds(const int &roundMilliseconds) { mRoundMilliseconds = roundMilliseconds; }
inline void setRestMilliseconds(const int &restMilliseconds) { mRestMilliseconds = restMilliseconds; }
void setPreset(const QString &preset);
private:
int mRounds;
int mRoundMilliseconds;
int mRestMilliseconds;
QList<int> mInnerTimers;
QString mPreset;
QString mPresetName;
void loadPreset();
void setDefaultPreset();
inline const QString convertRichNameToGroup(const QString &richName) { return richName.toLower().simplified().replace(" ", ""); }
signals:
void presetChanged();
};
#endif // BOXINGSETTINGS_H
BoxingSettings::setRestMilliseconds
void setRestMilliseconds(const int &restMilliseconds)
Setter for milliseconds of rest.
Definition: boxingsettings.h:170
BoxingSettings::setPreset
void setPreset(const QString &preset)
Setter for preset.
Definition: boxingsettings.cpp:26
BoxingSettings::getPreset
QString getPreset()
Definition: boxingsettings.h:139
BoxingSettings::presetsList
Q_INVOKABLE const QStringList presetsList()
Definition: boxingsettings.cpp:90
BoxingSettings::getInnerTimers
QList< int > getInnerTimers()
gerInnerTimers()
Definition: boxingsettings.h:132
BoxingSettings::setRounds
void setRounds(const int &rounds)
Setter for number of rounds.
Definition: boxingsettings.h:154
BoxingSettings::presetChanged
void presetChanged()
BoxingSettings::getRestMilliseconds
int getRestMilliseconds()
Definition: boxingsettings.h:125
BoxingSettings::getRoundMilliseconds
int getRoundMilliseconds()
Definition: boxingsettings.h:118
BoxingSettings::deletePreset
Q_INVOKABLE void deletePreset(const QString &name)
Delete a specified preset.
Definition: boxingsettings.cpp:78
BoxingSettings::getPresetName
QString getPresetName()
Definition: boxingsettings.h:146
BoxingSettings::getInnerTimer
Q_INVOKABLE int getInnerTimer(const int &index)
getInnerTimer(const int &index)
Definition: boxingsettings.cpp:100
BoxingSettings::savePreset
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::BoxingSettings
BoxingSettings()
Definition: boxingsettings.cpp:6
BoxingSettings::getRounds
int getRounds()
Definition: boxingsettings.h:111
BoxingSettings
Handle settings about timer. Can save, load and delete a specific preset.
Definition: boxingsettings.h:20
BoxingSettings::setRoundMilliseconds
void setRoundMilliseconds(const int &roundMilliseconds)
Setter for duration of round (in milliseconds)
Definition: boxingsettings.h:162