This commit is contained in:
Leonardo Murillo 2014-01-21 11:17:43 -06:00
parent cc147bc8bf
commit b2ef07f485
3 changed files with 7 additions and 16 deletions

View file

@ -36,6 +36,7 @@
#include <QNetworkReply>
#include <QNetworkDiskCache>
#include <QOpenGLFramebufferObject>
#include <QObject>
#include <QWheelEvent>
#include <QSettings>
#include <QShortcut>
@ -4402,16 +4403,12 @@ void Application::updateLocalOctreeCache(bool firstTime) {
}
void Application::checkVersion() {
qDebug() << "################### in check version";
QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL)));
latestVersionRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
_latestVersionReply = Application::getInstance()->getNetworkAccessManager()->get(latestVersionRequest);
connect(_latestVersionReply, SIGNAL(finished()), SLOT(parseVersionXml()));
connect(Application::getInstance()->getNetworkAccessManager()->get(latestVersionRequest), SIGNAL(finished()), SLOT(parseVersionXml()));
}
void Application::parseVersionXml() {
qDebug() << "################### in parse version xml";
#ifdef Q_OS_WIN32
QString operatingSystem("win");
@ -4430,7 +4427,7 @@ void Application::parseVersionXml() {
QString latestVersion;
QUrl downloadUrl;
QXmlStreamReader xml(_latestVersionReply);
QXmlStreamReader xml(qobject_cast<QNetworkReply*>(QObject::sender()));
while (!xml.atEnd() && !xml.hasError()) {
QXmlStreamReader::TokenType token = xml.readNext();
@ -4453,12 +4450,9 @@ void Application::parseVersionXml() {
}
}
}
if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl);
}
delete _latestVersionReply;
}
bool Application::shouldSkipVersion(QString latestVersion) {

View file

@ -208,7 +208,6 @@ public:
void setHighlightVoxel(const VoxelDetail& highlightVoxel) { _highlightVoxel = highlightVoxel; }
void setIsHighlightVoxel(bool isHighlightVoxel) { _isHighlightVoxel = isHighlightVoxel; }
QUrl _downloadUrl;
void skipVersion(QString latestVersion);
public slots:
@ -512,7 +511,6 @@ private:
void checkVersion();
void displayUpdateDialog();
bool shouldSkipVersion(QString latestVersion);
QNetworkReply* _latestVersionReply;
};
#endif /* defined(__interface__Application__) */

View file

@ -20,10 +20,9 @@
#include "UpdateDialog.h"
UpdateDialog::UpdateDialog(QWidget *parent, const QString& releaseNotes, const QString& latestVersion, const QUrl& downloadURL) :
QWidget(parent, Qt::Widget) {
_latestVersion = latestVersion;
_downloadUrl = downloadURL;
QWidget(parent, Qt::Widget),
_latestVersion(latestVersion),
_downloadUrl(downloadURL) {
QUiLoader updateDialogLoader;
QWidget* updateDialog;
@ -36,7 +35,7 @@ UpdateDialog::UpdateDialog(QWidget *parent, const QString& releaseNotes, const Q
.arg(Application::getInstance()->applicationVersion(), latestVersion);
setAttribute(Qt::WA_DeleteOnClose);
updateDialog->setAttribute(Qt::WA_DeleteOnClose);
QPushButton* downloadButton = updateDialog->findChild<QPushButton*>("downloadButton");
QPushButton* skipButton = updateDialog->findChild<QPushButton*>("skipButton");