forked from gatlin/QPurple
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqpurpletimer.cpp
More file actions
30 lines (23 loc) · 755 Bytes
/
qpurpletimer.cpp
File metadata and controls
30 lines (23 loc) · 755 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
#include "qpurple.h"
#include "qpurpletimer.h"
namespace QPurple {
QPurpleTimer::QPurpleTimer()
: func(NULL), data(NULL), defaultConstructed(1) {
}
QPurpleTimer::QPurpleTimer(GSourceFunc f, gpointer d, int i)
: func(f), data(d), defaultConstructed(0) {
this->timer = new QTimer();
this->timer->setInterval(i);
connect(this->timer, SIGNAL(timeout()),this, SLOT(callFunc()));
this->timer->start(i);
}
QPurpleTimer::~QPurpleTimer() {
this->timer->stop();
delete this->timer;
}
void QPurpleTimer::callFunc() {
gboolean res = this->func(this->data);
if (!res)
this->timer->stop();
}
}