Merge pull request #1974 from ZeldaZach/fix_updater
fix updater from bintray api issue
This commit is contained in:
commit
e3fb308ea1
4 changed files with 14 additions and 22 deletions
|
@ -85,6 +85,7 @@ void DlgUpdate::gotoDownloadPage() {
|
||||||
|
|
||||||
void DlgUpdate::downloadUpdate() {
|
void DlgUpdate::downloadUpdate() {
|
||||||
setLabel("Downloading update...");
|
setLabel("Downloading update...");
|
||||||
|
enableOkButton(false);
|
||||||
enableUpdateButton(false);
|
enableUpdateButton(false);
|
||||||
uDownloader->beginDownload(updateUrl);
|
uDownloader->beginDownload(updateUrl);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +128,8 @@ void DlgUpdate::finishedUpdateCheck(bool needToUpdate, bool isCompatible, QVaria
|
||||||
if (reply == QMessageBox::Yes)
|
if (reply == QMessageBox::Yes)
|
||||||
downloadUpdate();
|
downloadUpdate();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
QMessageBox::information(this, "Cockatrice Update",
|
QMessageBox::information(this, "Cockatrice Update",
|
||||||
tr("Your version of Cockatrice is out of date, but there are no packages"
|
tr("Your version of Cockatrice is out of date, but there are no packages"
|
||||||
" available for your operating system. You may have to use a developer build or build from source"
|
" available for your operating system. You may have to use a developer build or build from source"
|
||||||
|
@ -146,6 +148,10 @@ void DlgUpdate::enableUpdateButton(bool enable) {
|
||||||
manualDownload->setEnabled(enable);
|
manualDownload->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DlgUpdate::enableOkButton(bool enable) {
|
||||||
|
ok->setEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
void DlgUpdate::setLabel(QString newText) {
|
void DlgUpdate::setLabel(QString newText) {
|
||||||
text->setText(newText);
|
text->setText(newText);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
QUrl updateUrl;
|
QUrl updateUrl;
|
||||||
void enableUpdateButton(bool enable);
|
void enableUpdateButton(bool enable);
|
||||||
|
void enableOkButton(bool enable);
|
||||||
void beginUpdateCheck();
|
void beginUpdateCheck();
|
||||||
void setLabel(QString text);
|
void setLabel(QString text);
|
||||||
QLabel *text;
|
QLabel *text;
|
||||||
|
|
|
@ -43,24 +43,14 @@ bool UpdateChecker::downloadMatchesCurrentOS(QVariant build)
|
||||||
.contains("osx");
|
.contains("osx");
|
||||||
}
|
}
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
||||||
bool UpdateChecker::downloadMatchesCurrentOS(QVariant build)
|
bool UpdateChecker::downloadMatchesCurrentOS(QVariant build)
|
||||||
{
|
{
|
||||||
return build
|
return build
|
||||||
.toMap()["name"]
|
.toMap()["name"]
|
||||||
.toString()
|
.toString()
|
||||||
.contains("qt5.exe");
|
.contains("exe");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
bool UpdateChecker::downloadMatchesCurrentOS(QVariant build)
|
|
||||||
{
|
|
||||||
return build
|
|
||||||
.toMap()["name"]
|
|
||||||
.toString()
|
|
||||||
.contains("qt4.exe");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
|
|
||||||
bool UpdateChecker::downloadMatchesCurrentOS(QVariant)
|
bool UpdateChecker::downloadMatchesCurrentOS(QVariant)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +63,7 @@ bool UpdateChecker::downloadMatchesCurrentOS(QVariant)
|
||||||
QDate UpdateChecker::dateFromBuild(QVariant build)
|
QDate UpdateChecker::dateFromBuild(QVariant build)
|
||||||
{
|
{
|
||||||
QString formatString = "yyyy-MM-dd";
|
QString formatString = "yyyy-MM-dd";
|
||||||
QString dateString = build.toMap()["date"].toString();
|
QString dateString = build.toMap()["created"].toString();
|
||||||
dateString = dateString.remove(formatString.length(), dateString.length());
|
dateString = dateString.remove(formatString.length(), dateString.length());
|
||||||
|
|
||||||
return QDate::fromString(dateString, formatString);
|
return QDate::fromString(dateString, formatString);
|
||||||
|
|
|
@ -7,20 +7,15 @@ UpdateDownloader::UpdateDownloader(QObject *parent) : QObject(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateDownloader::beginDownload(QUrl downloadUrl) {
|
void UpdateDownloader::beginDownload(QUrl downloadUrl) {
|
||||||
|
|
||||||
//Save the original URL because we need it for the filename
|
//Save the original URL because we need it for the filename
|
||||||
if (originalUrl.isEmpty())
|
if (originalUrl.isEmpty())
|
||||||
originalUrl = downloadUrl;
|
originalUrl = downloadUrl;
|
||||||
|
|
||||||
response = netMan->get(QNetworkRequest(downloadUrl));
|
response = netMan->get(QNetworkRequest(downloadUrl));
|
||||||
connect(response, SIGNAL(finished()),
|
connect(response, SIGNAL(finished()), this, SLOT(fileFinished()));
|
||||||
this, SLOT(fileFinished()));
|
connect(response, SIGNAL(readyRead()), this, SLOT(fileReadyRead()));
|
||||||
connect(response, SIGNAL(readyRead()),
|
connect(response, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64)));
|
||||||
this, SLOT(fileReadyRead()));
|
connect(response, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError)));
|
||||||
connect(response, SIGNAL(downloadProgress(qint64, qint64)),
|
|
||||||
this, SLOT(downloadProgress(qint64, qint64)));
|
|
||||||
connect(response, SIGNAL(error(QNetworkReply::NetworkError)),
|
|
||||||
this, SLOT(downloadError(QNetworkReply::NetworkError)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateDownloader::downloadError(QNetworkReply::NetworkError) {
|
void UpdateDownloader::downloadError(QNetworkReply::NetworkError) {
|
||||||
|
|
Loading…
Reference in a new issue