This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
app/headers/speedtimer.h
dorian 0957a913f8 - cleanup
- implemented new state ('WAITING')
- multiple timers are now supported at the frontend
2019-04-15 13:33:31 +02:00

48 lines
996 B
C++

#ifndef SPEEDTIMER_H
#define SPEEDTIMER_H
#include <QObject>
#include <QDateTime>
#include <QEventLoop>
#include <QTimer>
#include <QDebug>
class SpeedTimer : public QObject
{
Q_OBJECT
public:
explicit SpeedTimer(QObject *parent = nullptr);
enum timerState { IDLE, STARTING, WAITING, RUNNING, STOPPED, FAILED, CANCELLED };
timerState state;
// variables for capturing the time
double startTime;
double stopTime;
double stoppedTime;
double reactionTime;
signals:
void stateChanged(timerState newState);
void startCanceled(bool falseStart);
public slots:
bool start(bool force = false);
bool stop(int type, bool force = false);
bool reset(bool force = false);
void setState(timerState newState);
QString getState();
double getCurrTime();
QString getText();
//helper functions
void delay(int mSecs);
timerState stateFromString(QString state);
private:
QDateTime *date;
};
#endif // SPEEDTIMER_H