-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathcountdownwidget.h
45 lines (35 loc) · 964 Bytes
/
countdownwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef COUNTDOWNWIDGET_H
#define COUNTDOWNWIDGET_H
#include <QWidget>
#include <QTimer>
#include <QDateTime>
namespace Ui {
class CountdownWidget;
}
/**
* @brief The CountdownWidget class
*
* Display a countdown timer that targets a QDateTime in the future
*/
class CountdownWidget : public QWidget
{
Q_OBJECT
public:
explicit CountdownWidget(QWidget *parent = nullptr);
~CountdownWidget();
QDateTime target; // The countdown target
QTimer timer; // The timer that updates the countdown periodically
bool showMillis = false; // Select whether to show milliseconds or not
QDateTime getTarget() const;
bool getShowMillis() const;
public slots:
void setTarget(const QDateTime &newTarget);
void setShowMillis(bool newShowMillis);
void toggleDisplay(bool on);
void start();
void stop();
void update();
private:
Ui::CountdownWidget *ui;
};
#endif // COUNTDOWNWIDGET_H