-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime.cpp
More file actions
89 lines (65 loc) · 1.64 KB
/
time.cpp
File metadata and controls
89 lines (65 loc) · 1.64 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "time.h"
Time::Time(QObject *parent) : QObject(parent)
{
m_timer = new QTimer();
m_pre_timer = new QTimer();
m_gui_time = QTime(0,0);
m_secs = m_gui_time.toString("mm:ss");
//emit timeChanged();
connect(m_timer,SIGNAL(timeout()),this,SLOT(update_Timer()));
connect(m_pre_timer,SIGNAL(timeout()),this,SLOT(update_Pre_Timer()));
}
void Time::pre_start_Round(int secs)
{
m_pre_timer->start(1000);
//Time initialization
m_gui_time = QTime(0,0,secs);
m_secs = m_gui_time.toString("-mm:ss");
emit changedTime();
}
void Time::start_Timer(){
m_timer->start(1000);
//Time initialization
m_gui_time = QTime(0,0);
m_secs = m_gui_time.toString("mm:ss");
emit changedTime();
m_round_time = QTime(0,0);
m_round_time.start();
}
void Time::stop_Timer()
{
// Miliseconds counting
int a = m_round_time.elapsed();
m_int_time = a;
m_gui_time = QTime(0,0);
m_gui_time = m_gui_time.addMSecs(a);
m_timer->stop();
m_secs = m_gui_time.toString("mm:ss.zzz");
emit changedTime();
}
void Time::update_Timer()
{
m_timeElapsed = m_round_time.elapsed();
m_gui_time = m_gui_time.addMSecs(1000);
m_secs = m_gui_time.toString("mm:ss");
emit changedTime();
}
void Time::update_Pre_Timer()
{
if (QTime(0,0,1) == m_gui_time)
{
m_pre_timer->stop();
this->start_Timer();
emit TimeIsOut();
}
else
{
if(QTime(0,0,6) == m_gui_time)
{
emit showText();
}
m_gui_time = m_gui_time.addMSecs(-1000);
m_secs = m_gui_time.toString("-mm:ss");
emit changedTime();
}
}