Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
ExerciseTimer.h
1/*
2 * ExerciseTimer.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2022 - adazem009
6 *
7 * Open-Typer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Open-Typer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Open-Typer. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef EXERCISETIMER_H
22#define EXERCISETIMER_H
23
24#include <QObject>
25#include <QElapsedTimer>
26
28class Q_DECL_EXPORT ExerciseTimer : public QObject
29{
30 Q_OBJECT
31 Q_PROPERTY(int elapsed MEMBER m_elapsed NOTIFY elapsedChanged)
32 Q_PROPERTY(bool running MEMBER m_running NOTIFY runningChanged)
33 public:
34 Q_INVOKABLE QString formattedTime(void);
35 Q_INVOKABLE QString formattedRemainingTime(int limitMSecs);
36 Q_INVOKABLE void update(void);
37
38 private:
39 QElapsedTimer m_timer;
40 bool m_running = false;
41 int m_elapsed = 0;
42
43 public slots:
44 void start(void);
45 void stop(void);
46
47 signals:
48 void runningChanged(void);
49 void elapsedChanged(void);
50};
51
52#endif // EXERCISETIMER_H
The ExerciseTimer class provides a simple elapsed timer for QML.
Definition ExerciseTimer.h:29