Preliminary update dialog work

This commit is contained in:
Leonardo Murillo 2014-01-08 21:20:43 -06:00
parent d44126ac33
commit efb173e1d4
5 changed files with 131 additions and 9 deletions

View file

@ -40,6 +40,7 @@
#include <QDesktopServices>
#include <QXmlStreamReader>
#include <QXmlStreamAttributes>
#include <QMessageBox>
#include <AudioInjector.h>
#include <NodeTypes.h>
@ -195,6 +196,18 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
setOrganizationName(applicationInfo.value("organizationName").toString());
setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
#ifdef Q_WS_X11
_operatingSystem = "ubuntu";
#endif
#ifdef Q_WS_WIN
_operatingSystem = "win";
#endif
#ifdef Q_WS_MACX
_operatingSystem = "mac";
#endif
checkVersion();
qDebug("[VERSION] Build sequence: %s\n", applicationVersion().toStdString().c_str());
@ -1419,6 +1432,7 @@ void Application::idle() {
}
}
}
void Application::terminate() {
// Close serial port
// close(serial_fd);
@ -4542,7 +4556,7 @@ void Application::toggleLogDialog() {
}
}
void Application::loadLatestVersionDetails() {
void Application::checkVersion() {
QUrl url("https://a-tower.below92.com/version.xml");
QNetworkAccessManager *downloadXML = new QNetworkAccessManager(this);
QNetworkRequest request(url);
@ -4552,28 +4566,56 @@ void Application::loadLatestVersionDetails() {
}
void Application::parseVersionXml(QNetworkReply *reply) {
QString _releaseDate;
QString _releaseNotes;
QString _downloadLink;
QXmlStreamReader xml(reply);
while (!xml.atEnd() && !xml.hasError()) {
QXmlStreamReader::TokenType token = xml.readNext();
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "ReleaseDate") {
xml.readNext();
_releaseDate = xml.text().toString();
}
if (xml.name() == "ReleaseNotes") {
xml.readNext();
_releaseNotes = xml.text().toString();
}
if (xml.name() == "Version") {
xml.readNext();
_latestVersion = xml.text().toString();
qDebug("################ Version found %s\n", _latestVersion.toStdString().c_str());
}
}
}
if (applicationVersion() != _latestVersion) {
}
displayUpdateDialog();
}
void Application::checkVersion() {
loadLatestVersionDetails();
void Application::displayUpdateDialog() {
int _windowWidth = 500;
int _windowHeigth = 300;
QString _windowTitle = "Newer build available";
// This is a very rudimentary check, if this version is not equal to latest then you need to get it
// unless you're coming from the future.
QPushButton *download = new QPushButton("Download");
QPushButton *ignore = new QPushButton("Ignore this version");
QPushButton *close = new QPushButton("Close");
QWidget *updateDialog = new QWidget;
updateDialog->setFixedWidth(_windowWidth);
updateDialog->setFixedHeight(_windowHeigth);
updateDialog->setWindowTitle(_windowTitle);
updateDialog->show();
//if (applicationVersion() != 0 && applicationVersion() != this->_latestVersion) {
//}
}

View file

@ -69,6 +69,7 @@
#include "ui/RearMirrorTools.h"
#include "ui/LodToolsDialog.h"
#include "ui/LogDialog.h"
#include "ui/UpdateDialog.h"
#include "FileLogger.h"
#include "ParticleTreeRenderer.h"
#include "ParticleEditHandle.h"
@ -215,8 +216,8 @@ public:
// Get XML with version information and parse it
// Display dialog when version is not the latest and allow for new version download from link
void loadLatestVersionDetails();
void checkVersion();
void displayUpdateDialog();
public slots:
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
@ -521,6 +522,7 @@ private:
FileLogger* _logger;
QString _latestVersion;
QString _operatingSystem;
};
#endif /* defined(__interface__Application__) */

View file

@ -0,0 +1,40 @@
//
// UpdateDialog.cpp
// interface
//
// Created by Leonardo Murillo <leo@highfidelity.io> on 1/8/14.
// Copyright (c) 2013, 2014 High Fidelity, Inc. All rights reserved.
//
#include <QDesktopWidget>
#include <QTextBlock>
#include <QtGui>
#include "SharedUtil.h"
#include "UpdateDialog.h"
const int buttonWidth = 120;
const int buttonHeight = 40;
const QString dialogTitle = "Update Required";
const QString updateRequired = QString("You are currently running build %1, the latest build released is %2.\n \
Please download and install the most recent release to access the latest \
features and bug fixes.").arg("1", "2");
UpdateDialog::UpdateDialog(QWidget *parent, QString releaseNotes, QString downloadURL) : QDialog(parent, Qt::Dialog) {
setWindowTitle(dialogTitle);
_releaseNotes = new QLabel(this);
_releaseNotes->setText(releaseNotes);
_updateRequired = new QLabel(this);
_updateRequired->setText(updateRequired);
_downloadButton = new QPushButton("Download", this);
_downloadButton->setObjectName("downloadButton");
_skipButton = new QPushButton("Skip Version", this);
_skipButton->setObjectName("skipButton");
_closeButton = new QPushButton("Close", this);
_closeButton->setObjectName("closeButton");
}

View file

@ -0,0 +1,38 @@
//
// UpdateDialog.h
// interface
//
// Created by Leonardo Murillo <leo@highfidelity.io> on 1/8/14.
// Copyright (c) 2013, 2014 High Fidelity, Inc. All rights reserved.
//
#ifndef __hifi__UpdateDialog__
#define __hifi__UpdateDialog__
#include <QDialog>
#include <QPushButton>
#include <QLabel>
#include <iostream>
class UpdateDialog : public QDialog {
Q_OBJECT
public:
UpdateDialog(QWidget*, QString releaseNotes, QString downloadURL);
~UpdateDialog();
private:
QLabel *_updateRequired;
QLabel *_releaseNotes;
QPushButton *_downloadButton;
QPushButton *_skipButton;
QPushButton *_closeButton;
private slots:
void handleDownload();
void handleIgnore();
void handleClose();
};
#endif /* defined(__hifi__UpdateDialog__) */