mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 17:03:58 +02:00
AutoUpdate is now a singleton invoked via Dependency Manager, first steps towards QML update notification
This commit is contained in:
parent
2aa7ce557a
commit
b60597aa90
8 changed files with 111 additions and 10 deletions
19
interface/resources/qml/UpdateDialog.qml
Normal file
19
interface/resources/qml/UpdateDialog.qml
Normal file
|
@ -0,0 +1,19 @@
|
|||
import Hifi 1.0
|
||||
import QtQuick 2.3
|
||||
import QtQuick.Controls.Styles 1.3
|
||||
import "controls"
|
||||
import "styles"
|
||||
|
||||
Rectangle {
|
||||
id: page
|
||||
width: 320; height: 480
|
||||
color: "lightgray"
|
||||
|
||||
Text {
|
||||
id: helloText
|
||||
text: "Hello world!"
|
||||
y: 30
|
||||
anchors.horizontalCenter: page.horizontalCenter
|
||||
font.pointSize: 24; font.bold: true
|
||||
}
|
||||
}
|
|
@ -143,6 +143,7 @@
|
|||
#include "ui/StandAloneJSConsole.h"
|
||||
#include "ui/Stats.h"
|
||||
#include "ui/AddressBarDialog.h"
|
||||
#include "ui/UpdateDialog.h"
|
||||
|
||||
// ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU
|
||||
#if defined(Q_OS_WIN)
|
||||
|
@ -290,6 +291,7 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
auto discoverabilityManager = DependencyManager::set<DiscoverabilityManager>();
|
||||
auto sceneScriptingInterface = DependencyManager::set<SceneScriptingInterface>();
|
||||
auto offscreenUi = DependencyManager::set<OffscreenUi>();
|
||||
auto autoUpdate = DependencyManager::set<AutoUpdate>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -612,7 +614,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
connect(ddeTracker.data(), &FaceTracker::muteToggled, this, &Application::faceTrackerMuteToggled);
|
||||
#endif
|
||||
|
||||
AutoUpdate* applicationUpdater = new AutoUpdate;
|
||||
auto applicationUpdater = DependencyManager::get<AutoUpdate>();
|
||||
connect(applicationUpdater.data(), SIGNAL(newVersionIsAvailable()), dialogsManager.data(), SLOT(showUpdateDialog()));
|
||||
applicationUpdater->checkForUpdate();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "OctreeStatsDialog.h"
|
||||
#include "PreferencesDialog.h"
|
||||
#include "ScriptEditorWindow.h"
|
||||
#include "UpdateDialog.h"
|
||||
|
||||
|
||||
void DialogsManager::toggleAddressBar() {
|
||||
|
@ -50,6 +51,11 @@ void DialogsManager::showLoginDialog() {
|
|||
LoginDialog::show();
|
||||
}
|
||||
|
||||
void DialogsManager::showUpdateDialog() {
|
||||
qDebug() << "[LEOTEST] We should be showing the update dialog";
|
||||
UpdateDialog::show();
|
||||
}
|
||||
|
||||
void DialogsManager::octreeStatsDetails() {
|
||||
if (!_octreeStatsDialog) {
|
||||
_octreeStatsDialog = new OctreeStatsDialog(qApp->getWindow(), qApp->getOcteeSceneStats());
|
||||
|
|
|
@ -35,6 +35,7 @@ class ScriptEditorWindow;
|
|||
class QMessageBox;
|
||||
class AvatarAppearanceDialog;
|
||||
class DomainConnectionDialog;
|
||||
class UpdateDialog;
|
||||
|
||||
class DialogsManager : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
|
@ -64,6 +65,9 @@ public slots:
|
|||
void showIRCLink();
|
||||
void changeAvatarAppearance();
|
||||
void showDomainConnectionDialog();
|
||||
|
||||
// Application Update
|
||||
void showUpdateDialog();
|
||||
|
||||
private slots:
|
||||
void toggleToolWindow();
|
||||
|
|
20
interface/src/ui/UpdateDialog.cpp
Normal file
20
interface/src/ui/UpdateDialog.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
//
|
||||
// UpdateDialog.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Leonardo Murillo on 6/3/15.
|
||||
//
|
||||
//
|
||||
|
||||
#include "UpdateDialog.h"
|
||||
#include "DependencyManager.h"
|
||||
|
||||
HIFI_QML_DEF(UpdateDialog)
|
||||
|
||||
UpdateDialog::UpdateDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) {
|
||||
|
||||
}
|
||||
|
||||
void UpdateDialog::hide() {
|
||||
((QQuickItem*)parent())->setEnabled(false);
|
||||
}
|
32
interface/src/ui/UpdateDialog.h
Normal file
32
interface/src/ui/UpdateDialog.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// UpdateDialog.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Leonardo Murillo on 6/3/15.
|
||||
//
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef __hifi__UpdateDialog__
|
||||
#define __hifi__UpdateDialog__
|
||||
|
||||
#include <OffscreenQmlDialog.h>
|
||||
|
||||
class UpdateDialog : public OffscreenQmlDialog {
|
||||
Q_OBJECT
|
||||
HIFI_QML_DECL
|
||||
|
||||
public:
|
||||
UpdateDialog(QQuickItem* parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
protected:
|
||||
void hide();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__UpdateDialog__) */
|
|
@ -25,7 +25,7 @@ AutoUpdate::AutoUpdate() {
|
|||
#ifdef Q_OS_LINUX
|
||||
_operatingSystem = "ubuntu";
|
||||
#endif
|
||||
//connect(this, SIGNAL(latestVersionDataParsed()), this, SLOT(debugBuildData()));
|
||||
connect(this, SIGNAL(latestVersionDataParsed()), this, SLOT(checkVersionAndNotify()));
|
||||
}
|
||||
|
||||
AutoUpdate::~AutoUpdate() {
|
||||
|
@ -43,7 +43,6 @@ void AutoUpdate::getLatestVersionData() {
|
|||
latestVersionRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(latestVersionRequest);
|
||||
connect(reply, SIGNAL(finished()), this, SLOT(parseLatestVersionData()));
|
||||
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(handleError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,6 +95,7 @@ void AutoUpdate::parseLatestVersionData() {
|
|||
xml.readNext();
|
||||
pullRequestNumber = xml.readElementText();
|
||||
appendBuildData(version, downloadUrl, releaseTime, releaseNotes, pullRequestNumber);
|
||||
releaseNotes = "";
|
||||
}
|
||||
|
||||
xml.readNext();
|
||||
|
@ -122,12 +122,21 @@ void AutoUpdate::debugBuildData() {
|
|||
}
|
||||
}
|
||||
|
||||
void AutoUpdate::performAutoUpdate() {
|
||||
void AutoUpdate::checkVersionAndNotify() {
|
||||
qDebug() << "[LEOTEST] We are checking and notifying for updates";
|
||||
int latestVersionAvailable = _builds.lastKey();
|
||||
if (QCoreApplication::applicationVersion() != "dev" &&
|
||||
QCoreApplication::applicationVersion().toInt() < latestVersionAvailable) {
|
||||
emit newVersionIsAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
void AutoUpdate::performAutoUpdate(int version) {
|
||||
|
||||
}
|
||||
|
||||
void AutoUpdate::downloadUpdateVersion() {
|
||||
|
||||
void AutoUpdate::downloadUpdateVersion(int version) {
|
||||
emit newVersionIsDownloaded();
|
||||
}
|
||||
|
||||
void AutoUpdate::appendBuildData(int versionNumber, QString downloadURL, QString releaseTime, QString releaseNotes, QString pullRequestNumber) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
@ -27,17 +28,22 @@
|
|||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamAttributes>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
|
||||
|
||||
const QUrl BUILDS_XML_URL("https://highfidelity.com/builds.xml");
|
||||
|
||||
class AutoUpdate : public QObject {
|
||||
class AutoUpdate : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
// Methods
|
||||
AutoUpdate();
|
||||
~AutoUpdate();
|
||||
|
||||
void checkForUpdate();
|
||||
QMap<int, QMap<QString, QString>> getBuildData() { return _builds; }
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -48,9 +54,7 @@ private:
|
|||
|
||||
// Methods
|
||||
void getLatestVersionData();
|
||||
void performAutoUpdate();
|
||||
void downloadUpdateVersion();
|
||||
QMap<int, QMap<QString, QString>> getBuildData() { return _builds; }
|
||||
void downloadUpdateVersion(int version);
|
||||
void appendBuildData(int versionNumber,
|
||||
QString downloadURL,
|
||||
QString releaseTime,
|
||||
|
@ -60,9 +64,13 @@ private:
|
|||
private slots:
|
||||
void parseLatestVersionData();
|
||||
void debugBuildData();
|
||||
void checkVersionAndNotify();
|
||||
void performAutoUpdate(int version);
|
||||
|
||||
signals:
|
||||
void latestVersionDataParsed();
|
||||
void newVersionIsAvailable();
|
||||
void newVersionIsDownloaded();
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue