Merge pull request #1532 from murillodigital/master

Update required query and notification
This commit is contained in:
Stephen Birarda 2014-01-21 09:55:25 -08:00
commit 7c5c71ec42
8 changed files with 370 additions and 11 deletions

View file

@ -15,7 +15,7 @@ set(SIXENSE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/Sixense)
if (DEFINED ENV{JOB_ID})
set(BUILD_SEQ $ENV{JOB_ID})
else ()
set(BUILD_SEQ "0")
set(BUILD_SEQ "dev")
endif ()
if (APPLE)
@ -80,6 +80,8 @@ find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5WebKit REQUIRED)
find_package(Qt5WebKitWidgets REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5UiTools REQUIRED)
if (APPLE)
set(MACOSX_BUNDLE_BUNDLE_NAME Interface)
@ -146,7 +148,7 @@ if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR)
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES})
endif (LIBOVR_FOUND AND NOT DISABLE_LIBOVR)
qt5_use_modules(${TARGET_NAME} Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets)
qt5_use_modules(${TARGET_NAME} Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools)
# include headers for interface and InterfaceConfig.
include_directories(

View file

@ -6,4 +6,4 @@
// Copyright (c) 2013 High Fidelity, Inc.. All rights reserved.
//
const int BUILD_VERSION = @BUILD_SEQ@;
const QString BUILD_VERSION = "@BUILD_SEQ@";

View file

@ -1,5 +1,4 @@
[INFO]
name=Interface
version=0.0.1
organizationName=High Fidelity
organizationDomain=highfidelity.io
organizationDomain=highfidelity.io

View file

@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>750</width>
<height>300</height>
</rect>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="windowTitle">
<string>Update Required</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>751</width>
<height>71</height>
</rect>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(236, 236, 236);</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<widget class="QLabel" name="updateDialog">
<property name="geometry">
<rect>
<x>240</x>
<y>10</y>
<width>271</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>36</pointsize>
<stylestrategy>PreferAntialias</stylestrategy>
<kerning>false</kerning>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(51, 51, 51);</string>
</property>
<property name="text">
<string>Update Required</string>
</property>
</widget>
</widget>
<widget class="QLabel" name="updateContent">
<property name="geometry">
<rect>
<x>100</x>
<y>110</y>
<width>561</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>18</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>360</x>
<y>240</y>
<width>364</width>
<height>40</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="downloadButton">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true"> background-color: #333333;
border-width: 0;
border-radius: 9px;
border-radius: 9px;
font-family: Arial;
font-size: 18px;
font-weight: 100;
color: #b7b7b7;
width: 120px;
height: 40px;</string>
</property>
<property name="text">
<string>Download</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="skipButton">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true"> background-color: #333333;
border-width: 0;
border-radius: 9px;
border-radius: 9px;
font-family: Arial;
font-size: 18px;
font-weight: 100;
color: #b7b7b7;
width: 120px;
height: 40px;</string>
</property>
<property name="text">
<string>Skip Version</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closeButton">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true"> background-color: #333333;
border-width: 0;
border-radius: 9px;
border-radius: 9px;
font-family: Arial;
font-size: 18px;
font-weight: 100;
color: #b7b7b7;
width: 120px;
height: 40px;</string>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -33,8 +33,10 @@
#include <QMenuBar>
#include <QMouseEvent>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkDiskCache>
#include <QOpenGLFramebufferObject>
#include <QObject>
#include <QWheelEvent>
#include <QSettings>
#include <QShortcut>
@ -43,6 +45,8 @@
#include <QtDebug>
#include <QFileDialog>
#include <QDesktopServices>
#include <QXmlStreamReader>
#include <QXmlStreamAttributes>
#include <AudioInjector.h>
#include <NodeTypes.h>
@ -91,6 +95,9 @@ const float MIRROR_FULLSCREEN_DISTANCE = 0.35f;
const float MIRROR_REARVIEW_DISTANCE = 0.65f;
const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f;
const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";
const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
QString messageWithNewLine = message + "\n";
fprintf(stdout, "%s", messageWithNewLine.toLocal8Bit().constData());
@ -160,8 +167,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
// call Menu getInstance static method to set up the menu
_window->setMenuBar(Menu::getInstance());
qDebug("[VERSION] Build sequence: %i", BUILD_VERSION);
unsigned int listenPort = 0; // bind to an ephemeral port by default
const char** constArgv = const_cast<const char**>(argv);
const char* portStr = getCmdOption(argc, constArgv, "--listenPort");
@ -195,9 +200,11 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
applicationInfo.beginGroup("INFO");
setApplicationName(applicationInfo.value("name").toString());
setApplicationVersion(applicationInfo.value("version").toString());
setApplicationVersion(BUILD_VERSION);
setOrganizationName(applicationInfo.value("organizationName").toString());
setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
qDebug() << "[VERSION] Build sequence: " << qPrintable(applicationVersion());
_settings = new QSettings(this);
@ -256,7 +263,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
// Set the sixense filtering
_sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
checkVersion();
}
Application::~Application() {
@ -1385,6 +1393,7 @@ void Application::idle() {
}
}
}
void Application::terminate() {
// Close serial port
// close(serial_fd);
@ -3960,7 +3969,7 @@ void Application::attachNewHeadToNode(Node* newNode) {
void Application::updateWindowTitle(){
QString title = "";
QString buildVersion = " (build " + QString::number(BUILD_VERSION) + ")";
QString buildVersion = " (build " + applicationVersion() + ")";
QString username = _profile.getUsername();
if(!username.isEmpty()){
title += _profile.getUsername();
@ -4346,7 +4355,6 @@ void Application::toggleLogDialog() {
}
}
void Application::initAvatarAndViewFrustum() {
updateAvatar(0.f);
}
@ -4393,3 +4401,72 @@ void Application::updateLocalOctreeCache(bool firstTime) {
}
}
}
void Application::checkVersion() {
QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL)));
latestVersionRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
connect(Application::getInstance()->getNetworkAccessManager()->get(latestVersionRequest), SIGNAL(finished()), SLOT(parseVersionXml()));
}
void Application::parseVersionXml() {
#ifdef Q_OS_WIN32
QString operatingSystem("win");
#endif
#ifdef Q_OS_MAC
QString operatingSystem("mac");
#endif
#ifdef Q_OS_LINUX
QString operatingSystem("ubuntu");
#endif
QString releaseDate;
QString releaseNotes;
QString latestVersion;
QUrl downloadUrl;
QObject* sender = QObject::sender();
QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender));
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();
}
if (xml.name() == operatingSystem) {
xml.readNext();
downloadUrl = QUrl(xml.text().toString());
}
}
}
if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl);
}
sender->deleteLater();
}
bool Application::shouldSkipVersion(QString latestVersion) {
QFile skipFile(SKIP_FILENAME);
skipFile.open(QIODevice::ReadWrite);
QString skipVersion(skipFile.readAll());
return (skipVersion == latestVersion || applicationVersion() == "dev");
}
void Application::skipVersion(QString latestVersion) {
QFile skipFile(SKIP_FILENAME);
skipFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
skipFile.seek(0);
skipFile.write(latestVersion.toStdString().c_str());
}

View file

@ -65,6 +65,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"
@ -206,6 +207,8 @@ public:
/// set a voxel which is to be rendered with a highlight
void setHighlightVoxel(const VoxelDetail& highlightVoxel) { _highlightVoxel = highlightVoxel; }
void setIsHighlightVoxel(bool isHighlightVoxel) { _isHighlightVoxel = isHighlightVoxel; }
void skipVersion(QString latestVersion);
public slots:
void domainChanged(const QString& domainHostname);
@ -253,6 +256,8 @@ private slots:
void restoreMirrorView();
void shrinkMirrorView();
void resetSensors();
void parseVersionXml();
void removeScriptName(const QString& fileNameString);
@ -502,6 +507,10 @@ private:
QString getLocalVoxelCacheFileName();
void updateLocalOctreeCache(bool firstTime = false);
void checkVersion();
void displayUpdateDialog();
bool shouldSkipVersion(QString latestVersion);
};
#endif /* defined(__interface__Application__) */

View file

@ -0,0 +1,61 @@
//
// 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 <QApplication>
#include <QDesktopWidget>
#include <QTextBlock>
#include <QtGui>
#include <QtUiTools>
#include <QPushButton>
#include <QLabel>
#include <QFrame>
#include "Application.h"
#include "SharedUtil.h"
#include "UpdateDialog.h"
UpdateDialog::UpdateDialog(QWidget *parent, const QString& releaseNotes, const QString& latestVersion, const QUrl& downloadURL) :
QWidget(parent, Qt::Widget),
_latestVersion(latestVersion),
_downloadUrl(downloadURL) {
QUiLoader updateDialogLoader;
QWidget* updateDialog;
QFile updateDialogUi("resources/ui/updateDialog.ui");
updateDialogUi.open(QFile::ReadOnly);
updateDialog = updateDialogLoader.load(&updateDialogUi, this);
QString updateRequired = QString("You are currently running build %1, the latest build released is %2. \
Please download and install the most recent release to access the latest features and bug fixes.")
.arg(Application::getInstance()->applicationVersion(), latestVersion);
updateDialog->setAttribute(Qt::WA_DeleteOnClose);
QPushButton* downloadButton = updateDialog->findChild<QPushButton*>("downloadButton");
QPushButton* skipButton = updateDialog->findChild<QPushButton*>("skipButton");
QPushButton* closeButton = updateDialog->findChild<QPushButton*>("closeButton");
QLabel* updateContent = updateDialog->findChild<QLabel*>("updateContent");
updateContent->setText(updateRequired);
connect(downloadButton, SIGNAL(released()), this, SLOT(handleDownload()));
connect(skipButton, SIGNAL(released()), this, SLOT(handleSkip()));
connect(closeButton, SIGNAL(released()), this, SLOT(close()));
updateDialog->show();
}
void UpdateDialog::handleDownload() {
QDesktopServices::openUrl(_downloadUrl);
Application::getInstance()->quit();
}
void UpdateDialog::handleSkip() {
Application::getInstance()->skipVersion(_latestVersion);
this->close();
}

View file

@ -0,0 +1,29 @@
//
// 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 <QWidget>
class UpdateDialog : public QWidget {
Q_OBJECT
public:
UpdateDialog(QWidget* parent, const QString& releaseNotes, const QString& latestVersion, const QUrl& downloadURL);
private:
QString _latestVersion;
QUrl _downloadUrl;
private slots:
void handleDownload();
void handleSkip();
};
#endif /* defined(__hifi__UpdateDialog__) */