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/speedtimerqmladapter.h

52 lines
1.1 KiB
C++

#ifndef SPEEDTIMERQMLADAPTER_H
#define SPEEDTIMERQMLADAPTER_H
#include <QObject>
#include <QTimer>
#include "speedtimer.h"
class SpeedTimerQmlAdapter : public QObject
{
Q_OBJECT
Q_PROPERTY(QString state READ getState NOTIFY stateChanged)
//Q_PROPERTY(int currtime READ getCurrTime)
Q_PROPERTY(QString text READ getText NOTIFY textChanged)
public:
explicit SpeedTimerQmlAdapter(QObject *parent = nullptr);
SpeedTimer::timerState state;
// variables for capturing the time
double startTime;
double stopTime;
double stoppedTime;
double reactionTime;
QString text;
signals:
void stateChanged(SpeedTimer::timerState newState);
Q_SIGNAL void startCanceled(bool falseStart);
void textChanged();
public slots:
Q_INVOKABLE bool setStarting();
Q_INVOKABLE bool start();
Q_INVOKABLE bool stop(QString type);
Q_INVOKABLE bool reset();
void setState(SpeedTimer::timerState newState);
Q_INVOKABLE QString getState();
Q_INVOKABLE QString getText();
// double getCurrTime();
private:
QTimer * refreshTimer;
private slots:
void refreshValues();
};
#endif // SPEEDTIMERQMLADAPTER_H