fix updater from bintray api issue

This commit is contained in:
Zach H 2016-05-07 21:28:45 -04:00
parent ff1091ac02
commit d46cdd8044
4 changed files with 17 additions and 13 deletions

View file

@ -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);
} }

View file

@ -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;

View file

@ -49,7 +49,8 @@ bool UpdateChecker::downloadMatchesCurrentOS(QVariant build)
return build return build
.toMap()["name"] .toMap()["name"]
.toString() .toString()
.contains("qt5.exe"); .contains("qt5")
.contains("exe");
} }
#else #else
bool UpdateChecker::downloadMatchesCurrentOS(QVariant build) bool UpdateChecker::downloadMatchesCurrentOS(QVariant build)
@ -57,7 +58,8 @@ bool UpdateChecker::downloadMatchesCurrentOS(QVariant build)
return build return build
.toMap()["name"] .toMap()["name"]
.toString() .toString()
.contains("qt4.exe"); .contains("qt4")
.contains("exe");
} }
#endif #endif
#else #else
@ -73,7 +75,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);

View file

@ -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) {