-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.cpp
51 lines (44 loc) · 971 Bytes
/
worker.cpp
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
#include "worker.h"
#include <QDebug>
#include <QTime>
#include <QLatin1Char>
#include <QThread>
#include <math.h>
Worker::Worker(QObject *parent) :
QObject(parent)
{
giStopFlag = 0;
minutes = 0;
seconds = 0;
time = 0;
milis = 0;
start = 0;
}
void Worker::launchChrono()
{
gobTime = QTime::currentTime();
gobTime.start();
QThread::msleep(20);
time += gobTime.elapsed();
milis = time % 1000;
if(time >= 1000){
time = time - 1000;
seconds++;
}
if(seconds == 60){
if(time >= 1000) time = time - 1000;
seconds = 0;
minutes++;
}
emit(resultReady(QString("%3:%2:%1")
.arg(milis/10,2,10,QLatin1Char('0'))
.arg(seconds,2,10,QLatin1Char('0'))
.arg(minutes,2,10,QLatin1Char('0'))));
}
void Worker::resetChrono()
{
milis = 0;
seconds = 0;
minutes = 0;
time = 0;
}