-
Notifications
You must be signed in to change notification settings - Fork 2
/
launcherupdate.cpp
83 lines (70 loc) · 3.04 KB
/
launcherupdate.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
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
#include "launcherupdate.h"
#include "ui_launcherupdate.h"
launcherUpdate::launcherUpdate(QWidget *parent) :
QDialog(parent),
ui(new Ui::launcherUpdate) {
qInfo() << "launcherUpdate::launcherUpdate: constructor";
ui->setupUi(this);
this->setWindowFlags(this->windowFlags() ^ Qt::WindowContextHelpButtonHint ^ Qt::WindowCloseButtonHint);
}
launcherUpdate::~launcherUpdate() {
delete ui;
}
// Новая версия
void launcherUpdate::newVersion(Settings settings, QString version) {
qInfo() << "launcherUpdate::newVersion: start select";
// Применение стиля
if(settings.style == 0) {
QIcon icon1;
icon1.addFile(QStringLiteral(":/myresources/IMG/refresh57.png"), QSize(), QIcon::Normal, QIcon::Off);
ui->updateNow->setIcon(icon1);
QIcon icon2;
icon2.addFile(QStringLiteral(":/myresources/IMG/update8.png"), QSize(), QIcon::Normal, QIcon::Off);
ui->updateAfter->setIcon(icon2);
QIcon icon3;
icon3.addFile(QStringLiteral(":/myresources/IMG/power buttons1.png"), QSize(), QIcon::Normal, QIcon::Off);
ui->updateLater->setIcon(icon3);
} else {
QIcon icon1;
icon1.addFile(QStringLiteral(":/myresources/IMG/darkstyle/refresh57.png"), QSize(), QIcon::Normal, QIcon::Off);
ui->updateNow->setIcon(icon1);
QIcon icon2;
icon2.addFile(QStringLiteral(":/myresources/IMG/darkstyle/update8.png"), QSize(), QIcon::Normal, QIcon::Off);
ui->updateAfter->setIcon(icon2);
QIcon icon3;
icon3.addFile(QStringLiteral(":/myresources/IMG/darkstyle/power buttons1.png"), QSize(), QIcon::Normal, QIcon::Off);
ui->updateLater->setIcon(icon3);
}
ui->label->setText("Изменения в новой версии " + version);
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadPatchnotesFinished(QNetworkReply*)));
manager->get(QNetworkRequest(QUrl("http://launcher.our-army.su/download/updater/patchnotes")));
}
// Конец загрузки патч нотов
void launcherUpdate::downloadPatchnotesFinished(QNetworkReply *reply) {
if(reply->error()) {
qInfo() << "launcherUpdate::downloadPatchnotesFinished: reply error" << reply->errorString();
ui->textBrowser->setText(reply->errorString());
} else {
qInfo() << "launcherUpdate::downloadPatchnotesFinished: download succ";
ui->textBrowser->setText(reply->readAll());
}
this->show();
}
// Обновится сейчас
void launcherUpdate::on_updateNow_clicked() {
qInfo() << "launcherUpdate::on_updateNow_clicked: update now";
emit result(0);
this->close();
}
// Обновится позже
void launcherUpdate::on_updateAfter_clicked() {
qInfo() << "launcherUpdate::on_updateAfter_clicked: update after";
emit result(1);
this->close();
}
// Не обновлятся
void launcherUpdate::on_updateLater_clicked() {
qInfo() << "launcherUpdate::on_updateLater_clicked: update later";
this->close();
}