mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 20:03:00 +02:00
- Strip out "<br />"s - Show information for all new versions since current, not just latest - Display scrollbar if content too long to show all at once - "version" / "versions" behind depending on if one or more - Align buttons with heading and text - Darken text so that is more readable
63 lines
No EOL
1.9 KiB
C++
63 lines
No EOL
1.9 KiB
C++
//
|
|
// 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 <AutoUpdater.h>
|
|
|
|
#include "DependencyManager.h"
|
|
|
|
HIFI_QML_DEF(UpdateDialog)
|
|
|
|
UpdateDialog::UpdateDialog(QQuickItem* parent) :
|
|
OffscreenQmlDialog(parent)
|
|
{
|
|
auto applicationUpdater = DependencyManager::get<AutoUpdater>();
|
|
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("<br />");
|
|
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<AutoUpdater>();
|
|
applicationUpdater.data()->performAutoUpdate(applicationUpdater.data()->getBuildData().lastKey());
|
|
} |