-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservertimer.cpp
More file actions
45 lines (36 loc) · 919 Bytes
/
servertimer.cpp
File metadata and controls
45 lines (36 loc) · 919 Bytes
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
#include "servertimer.h"
ServerTimer::ServerTimer(QObject *parent) : QObject(parent) {
connect(&graphTimer, &QTimer::timeout, this, &ServerTimer::UpdateGraphTime);
graphTime = 0;
}
ServerTimer& ServerTimer::GetInstance(){
static ServerTimer instance;
return instance;
}
qreal ServerTimer::Time(){
return graphTime;
}
QTimer& ServerTimer::Timer(){
return graphTimer;
}
void ServerTimer::ResetTime(){
graphTime = 0;
}
void ServerTimer::SetTime(qreal _time){
graphTime = _time;
}
void ServerTimer::RunFreChanged(int run){
if(run){
graphTimer.start();
}
else{
graphTimer.stop();
}
}
void ServerTimer::UpdatePeriodChanged(QString txt){
if(graphTimer.isActive()) graphTimer.start(txt.toInt());
else graphTimer.setInterval(txt.toInt());
}
void ServerTimer::UpdateGraphTime(){
graphTime += static_cast<qreal>(graphTimer.interval()) / 1000;
}