-
Notifications
You must be signed in to change notification settings - Fork 0
/
host.cpp
51 lines (44 loc) · 811 Bytes
/
host.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 "host.h"
#include <qdebug.h>
Host::Host()
{
time = 0;
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
connect(this, SIGNAL(isTimeUpSignal()), this, SLOT(chek()));
connect(this,SIGNAL(amountOfTimeHaveChanged()), this, SLOT(returnOfValue()));
}
void Host::startOfTimer(QObject *object, int amountOfTime)
{
timer->start(1000);
obj = object;
time = amountOfTime;
}
void Host::chek()
{
if (time == 0)
{
emit timeIsUp();
}
}
void Host::counting(int amountOfTime)
{
time = amountOfTime;
}
int Host::returnOfValue()
{
return time;
}
void Host::update()
{
obj->setProperty("text",time);
emit isTimeUpSignal();
if (time != 0)
{
time = time - 1;
}
else
{
time = 0;
timer->stop();
}
}