mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-18 17:40:48 +02:00
Code review fixes
This commit is contained in:
parent
79f0dd7d22
commit
fd25c76664
@ -32,7 +32,7 @@ set(launcher_SRCS
|
|||||||
mainwindow_moc.cpp
|
mainwindow_moc.cpp
|
||||||
launcherdirs.cpp
|
launcherdirs.cpp
|
||||||
jsonutils.cpp
|
jsonutils.cpp
|
||||||
updatedialog_moc.cpp
|
updatedialog_moc.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(launcher_HEADERS
|
set(launcher_HEADERS
|
||||||
@ -42,7 +42,7 @@ set(launcher_HEADERS
|
|||||||
mainwindow_moc.h
|
mainwindow_moc.h
|
||||||
launcherdirs.h
|
launcherdirs.h
|
||||||
jsonutils.h
|
jsonutils.h
|
||||||
updatedialog_moc.h
|
updatedialog_moc.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(launcher_FORMS
|
set(launcher_FORMS
|
||||||
@ -50,7 +50,7 @@ set(launcher_FORMS
|
|||||||
modManager/imageviewer_moc.ui
|
modManager/imageviewer_moc.ui
|
||||||
settingsView/csettingsview_moc.ui
|
settingsView/csettingsview_moc.ui
|
||||||
mainwindow_moc.ui
|
mainwindow_moc.ui
|
||||||
updatedialog_moc.ui
|
updatedialog_moc.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
assign_source_group(${launcher_SRCS} ${launcher_HEADERS} VCMI_launcher.rc)
|
assign_source_group(${launcher_SRCS} ${launcher_HEADERS} VCMI_launcher.rc)
|
||||||
|
@ -83,7 +83,7 @@ MainWindow::MainWindow(QWidget * parent)
|
|||||||
connect(ui->tabSelectList, SIGNAL(currentRowChanged(int)),
|
connect(ui->tabSelectList, SIGNAL(currentRowChanged(int)),
|
||||||
ui->tabListWidget, SLOT(setCurrentIndex(int)));
|
ui->tabListWidget, SLOT(setCurrentIndex(int)));
|
||||||
|
|
||||||
if(settings["launcher"]["updateOnStartup"].Bool() == true)
|
if(settings["launcher"]["updateOnStartup"].Bool())
|
||||||
UpdateDialog::showUpdateDialog(false);
|
UpdateDialog::showUpdateDialog(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ void CSettingsView::loadSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CSettingsView::CSettingsView(QWidget * parent)
|
CSettingsView::CSettingsView(QWidget * parent)
|
||||||
: QWidget(parent), ui(new Ui::CSettingsView)
|
: QWidget(parent), ui(new Ui::CSettingsView)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "../lib/CConfigHandler.h"
|
#include "../lib/CConfigHandler.h"
|
||||||
#include "../lib/GameConstants.h"
|
#include "../lib/GameConstants.h"
|
||||||
|
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ UpdateDialog::UpdateDialog(QWidget *parent, bool calledManually) :
|
|||||||
|
|
||||||
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||||
|
|
||||||
if(settings["launcher"]["updateOnStartup"].Bool() == true)
|
if(settings["launcher"]["updateOnStartup"].Bool())
|
||||||
ui->checkOnStartup->setCheckState(Qt::CheckState::Checked);
|
ui->checkOnStartup->setCheckState(Qt::CheckState::Checked);
|
||||||
|
|
||||||
currentVersion = GameConstants::VCMI_VERSION;
|
currentVersion = GameConstants::VCMI_VERSION;
|
||||||
@ -53,14 +52,12 @@ UpdateDialog::UpdateDialog(QWidget *parent, bool calledManually) :
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString url = QString::fromStdString(settings["launcher"]["updateConfigUrl"].String());
|
QString url = QString::fromStdString(settings["launcher"]["updateConfigUrl"].String());
|
||||||
|
|
||||||
QScopedPointer<QNetworkAccessManager> manager(new QNetworkAccessManager);
|
QNetworkReply *response = networkManager.get(QNetworkRequest(QUrl(url)));
|
||||||
|
|
||||||
QNetworkReply *response = manager->get(QNetworkRequest(QUrl(url)));
|
|
||||||
|
|
||||||
QObject::connect(response, &QNetworkReply::finished, [&, response]{
|
QObject::connect(response, &QNetworkReply::finished, [&, response]{
|
||||||
response->deleteLater();
|
response->deleteLater();
|
||||||
response->manager()->deleteLater();
|
|
||||||
if(response->error() != QNetworkReply::NoError)
|
if(response->error() != QNetworkReply::NoError)
|
||||||
{
|
{
|
||||||
ui->versionLabel->setStyleSheet("QLabel { background-color : red; color : black; }");
|
ui->versionLabel->setStyleSheet("QLabel { background-color : red; color : black; }");
|
||||||
@ -72,8 +69,7 @@ UpdateDialog::UpdateDialog(QWidget *parent, bool calledManually) :
|
|||||||
auto byteArray = response->readAll();
|
auto byteArray = response->readAll();
|
||||||
JsonNode node(byteArray.constData(), byteArray.size());
|
JsonNode node(byteArray.constData(), byteArray.size());
|
||||||
loadFromJson(node);
|
loadFromJson(node);
|
||||||
|
});
|
||||||
}) && manager.take();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateDialog::~UpdateDialog()
|
UpdateDialog::~UpdateDialog()
|
||||||
@ -122,13 +118,17 @@ void UpdateDialog::loadFromJson(const JsonNode & node)
|
|||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node["updateType"].String() == "minor")
|
const auto updateType = node["updateType"].String();
|
||||||
ui->versionLabel->setStyleSheet("QLabel { background-color : gray; color : black; }");
|
|
||||||
if(node["updateType"].String() == "major")
|
|
||||||
ui->versionLabel->setStyleSheet("QLabel { background-color : orange; color : black; }");
|
|
||||||
if(node["updateType"].String() == "critical")
|
|
||||||
ui->versionLabel->setStyleSheet("QLabel { background-color : red; color : black; }");
|
|
||||||
|
|
||||||
|
QString bgColor;
|
||||||
|
if(updateType == "minor")
|
||||||
|
bgColor = "gray";
|
||||||
|
else if(updateType == "major")
|
||||||
|
bgColor = "orange";
|
||||||
|
else if(updateType == "critical")
|
||||||
|
bgColor = "red";
|
||||||
|
|
||||||
|
ui->versionLabel->setStyleSheet(QLatin1String("QLabel { background-color : %1; color : black; }").arg(bgColor));
|
||||||
ui->versionLabel->setText(QString::fromStdString(newVersion));
|
ui->versionLabel->setText(QString::fromStdString(newVersion));
|
||||||
ui->plainTextEdit->setPlainText(QString::fromStdString(node["changeLog"].String()));
|
ui->plainTextEdit->setPlainText(QString::fromStdString(node["changeLog"].String()));
|
||||||
|
|
||||||
@ -136,8 +136,5 @@ void UpdateDialog::loadFromJson(const JsonNode & node)
|
|||||||
if(node["downloadLinks"][platformParameter].getType() == JsonNode::JsonType::DATA_STRING)
|
if(node["downloadLinks"][platformParameter].getType() == JsonNode::JsonType::DATA_STRING)
|
||||||
downloadLink = QString::fromStdString(node["downloadLinks"][platformParameter].String());
|
downloadLink = QString::fromStdString(node["downloadLinks"][platformParameter].String());
|
||||||
|
|
||||||
QString downloadHtml("<a href=\"");
|
ui->downloadLink->setText(QString{"<a href=\"%1\">link</a>"}.arg(downloadLink));
|
||||||
downloadHtml += downloadLink + "\">link</a>";
|
|
||||||
|
|
||||||
ui->downloadLink->setText(downloadHtml);
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
|
||||||
class JsonNode;
|
class JsonNode;
|
||||||
|
|
||||||
@ -35,6 +36,8 @@ private:
|
|||||||
std::string currentVersion;
|
std::string currentVersion;
|
||||||
std::string platformParameter = "other";
|
std::string platformParameter = "other";
|
||||||
|
|
||||||
|
QNetworkAccessManager networkManager;
|
||||||
|
|
||||||
bool calledManually;
|
bool calledManually;
|
||||||
|
|
||||||
void loadFromJson(const JsonNode & node);
|
void loadFromJson(const JsonNode & node);
|
||||||
|
Loading…
Reference in New Issue
Block a user