// // UpdateDialog.cpp // interface/src/ui // // Created by Leonardo Murillo on 6/3/15. // Copyright 2015 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include "UpdateDialog.h" #include #include "DependencyManager.h" HIFI_QML_DEF(UpdateDialog) UpdateDialog::UpdateDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) { auto applicationUpdater = DependencyManager::get(); int currentVersion = QCoreApplication::applicationVersion().toInt(); int latestVersion = applicationUpdater.data()->getBuildData().lastKey(); int versionsBehind = latestVersion - currentVersion; _updateAvailableDetails = "v" + QString::number(latestVersion) + " released on " + applicationUpdater.data()->getBuildData()[latestVersion]["releaseTime"]; _updateAvailableDetails += "\nYou are " + QString::number(versionsBehind) + " version" + (versionsBehind > 1 ? "s" : "") + " behind"; _releaseNotes = ""; for (int i = latestVersion; i > currentVersion; i--) { QString releaseNotes = applicationUpdater.data()->getBuildData()[i]["releaseNotes"]; releaseNotes.remove("
"); releaseNotes.remove(QRegExp("^\n")); _releaseNotes += releaseNotes; if (i > currentVersion + 1) { _releaseNotes += "\n\n"; } } } const QString& UpdateDialog::updateAvailableDetails() const { return _updateAvailableDetails; } const QString& UpdateDialog::releaseNotes() const { return _releaseNotes; } void UpdateDialog::closeDialog() { hide(); } void UpdateDialog::hide() { ((QQuickItem*)parent())->setEnabled(false); } void UpdateDialog::triggerUpgrade() { auto applicationUpdater = DependencyManager::get(); applicationUpdater.data()->performAutoUpdate(applicationUpdater.data()->getBuildData().lastKey()); }