-
Notifications
You must be signed in to change notification settings - Fork 0
/
timetracker.h
47 lines (37 loc) · 912 Bytes
/
timetracker.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
46
47
#ifndef TIMETRACKER_H
#define TIMETRACKER_H
#include <QObject>
#include <QtGlobal>
#include <QElapsedTimer>
#include <vector>
#include <memory>
#include "settings.h"
#include "types.h"
class TimeTracker : public QObject
{
Q_OBJECT
private:
enum class Mode {Activity, Pause, None};
const Settings & settings_;
QElapsedTimer timer_;
std::vector<qint64> activities_;
std::vector<qint64> pauses_;
Mode mode_;
bool was_active_before_autopause_;
qint64 getActiveTime() const;
qint64 getPauseTime() const;
void startTimer();
void stopTimer();
void pauseTimer();
void backpauseTimer();
public:
explicit TimeTracker(const Settings & settings, QObject *parent = nullptr);
~TimeTracker();
signals:
void sendAllTimes(qint64 t_active, qint64 t_pause);
public slots:
void useTimerViaButton(Button button);
void useTimerViaLockEvent(LockEvent event);
void sendTimes();
};
#endif // TIMETRACKER_H