-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathchekver.cpp
More file actions
68 lines (49 loc) · 1.5 KB
/
chekver.cpp
File metadata and controls
68 lines (49 loc) · 1.5 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
#include "chekver.h"
#define URL "http://bthub.net/download/battletech-character-creator-2/"
ChkVer::ChkVer(QWidget *parent, QString ver):
QWidget(parent)
{
verApp = ver;
verNow.clear();
trayIcon = new QSystemTrayIcon(this);
QIcon icon = QIcon(":/img/ico1.ico");
trayIcon->setIcon(icon);
if(CheckVersionNetwork() != true ) {
ShowMessage();
ShowMessage();
}
}
bool ChkVer::CheckVersionNetwork() {
bool chk = true;
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkRequest request;
request.setUrl(QUrl(URL));
QNetworkReply *reply(manager->get(QNetworkRequest(request)));
QEventLoop *loop = new QEventLoop;
connect(manager, SIGNAL(finished(QNetworkReply*)),loop,SLOT(quit()));
loop->exec();
reply->deleteLater();
if(!reply->readLine().isEmpty()) {
QStringList buf;
while(!reply->atEnd()) {
buf << reply->readLine();
}
for(int i =0; i< buf.count(); i++) {
if(buf[i].toLower().contains("last:")) {
verNow = buf[i].split(" ")[1];
}
}
}
if(verNow != verApp) {
chk = false;
}
if(verNow == "") {
chk = true;
}
return chk;
}
void ChkVer::ShowMessage() {
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(1);
trayIcon->showMessage("Battletech Character Creator","New version available! Download now! http://bthub.net", icon, 16000);
trayIcon->show();
}