-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimerform.h
More file actions
73 lines (66 loc) · 1.61 KB
/
timerform.h
File metadata and controls
73 lines (66 loc) · 1.61 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef TIMERFORM_H
#define TIMERFORM_H
#include <QMainWindow>
#include <QPushButton>
#include <QTimer>
#include <QMessageBox>
QT_BEGIN_NAMESPACE
namespace Ui { class TimerForm; }
QT_END_NAMESPACE
/*!
* \brief The LongRestLength enum
* \list
* \li Canceled - closed the form without pressing something\n
* \li Short15 - user requested a 15 minute long rest
* \li Long30 - user requested a 30 minute long rest
* \endlist
*/
enum LongRestLength
{
Canceled,
Short15 = QMessageBox::ButtonRole::NoRole,
Long30 = QMessageBox::ButtonRole::YesRole
};
enum SessionType
{
Undefined,
LongRest,
ShortRest,
Focus
};
class TimerForm : public QMainWindow
{
Q_OBJECT
const QString clockLabelFormat = "<b style=\"font-size:30pt\">%1</b>";
public:
TimerForm(QWidget *parent = nullptr);
~TimerForm();
protected:
void setupConnections();
void doFocusSession();
void pauseSession();
void resumeSession();
void doShortBreak();
void doLongBreak();
LongRestLength queryLongBreakLength();
void updateClock(int milliseconds);
bool lastSessionWasBreak() const;
void startSessionTimer(int minutes);
protected slots:
void onStartClicked();
void onShortTimerClicked();
void onLongTimerClicked();
void onClockUpdate();
void stopSession();
void onSettings();
private:
Ui::TimerForm *ui{nullptr};
int focusSessionCount{0};
int countSinceLastLongRest{0};
bool sessionRunning{false};
bool paused{false};
SessionType lastSessionType{SessionType::Undefined};
QTimer sessionTimer;
QTimer clockUpdateTimer;
};
#endif // TIMERFORM_H