diff --git a/interface/resources/qml/UpdateDialog.qml b/interface/resources/qml/UpdateDialog.qml index a7e91349a6..a823bfff79 100644 --- a/interface/resources/qml/UpdateDialog.qml +++ b/interface/resources/qml/UpdateDialog.qml @@ -4,69 +4,108 @@ import QtQuick.Controls.Styles 1.3 import "controls" import "styles" -UpdateDialog { +DialogContainer { HifiConstants { id: hifi } - id: updateDialog + id: root objectName: "UpdateDialog" - implicitWidth: backgroundImage.width - implicitHeight: backgroundImage.height + releaseNotes.height + implicitWidth: updateDialog.width + implicitHeight: updateDialog.height x: parent ? parent.width / 2 - width / 2 : 0 y: parent ? parent.height / 2 - height / 2 : 0 - Image { - id: backgroundImage - source: "../images/update-available.svg" - width: 576 - height: 80 - smooth: true + UpdateDialog { + id: updateDialog - Text { - id: updateAvailableTitle - text: "Update available" - color: "#000000" - x: 90 - y: 17 - } + implicitWidth: backgroundRectangle.width + implicitHeight: backgroundRectangle.height - Text { - id: updateAvailableDetails - text: updateDialog.updateAvailableDetails - width: parent.width - anchors.top: updateAvailableTitle.bottom - anchors.topMargin: 3 - font.pixelSize: 15 - color: "#545454" - x: 90 + readonly property int inputWidth: 500 + readonly property int inputHeight: 60 + readonly property int borderWidth: 30 + readonly property int closeMargin: 16 + readonly property int inputSpacing: 16 + + Column { + id: mainContent + width: updateDialog.inputWidth + spacing: updateDialog.inputSpacing + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + + Rectangle { + id: backgroundRectangle + color: "#2c86b1" + opacity: 0.85 + radius: updateDialog.closeMargin * 2 + + width: updateDialog.inputWidth + updateDialog.borderWidth * 2 + height: updateDialog.inputHeight * 6 + updateDialog.closeMargin * 2 + + Rectangle { + id: dialogTitle + width: updateDialog.inputWidth + height: updateDialog.inputHeight + radius: height / 2 + color: "#ebebeb" + + anchors { + top: parent.top + topMargin: updateDialog.inputSpacing + horizontalCenter: parent.horizontalCenter + } + + Text { + id: updateAvailableText + text: "Update Available" + anchors { + verticalCenter: parent.verticalCenter + left: parent.left + leftMargin: updateDialog.inputSpacing + } + } + + Text { + text: updateDialog.updateAvailableDetails + font.pixelSize: 14 + color: hifi.colors.text + anchors { + verticalCenter: parent.verticalCenter + left: updateAvailableText.right + leftMargin: 13 + } + } + } + + Flickable { + id: scrollArea + anchors { + top: dialogTitle.bottom + } + contentWidth: updateDialog.inputWidth + contentHeight: backgroundRectangle.height - (dialogTitle.height * 2) + width: updateDialog.inputWidth + height: backgroundRectangle.height - (dialogTitle.height * 2) + flickableDirection: Flickable.VerticalFlick + clip: true + + TextEdit { + id: releaseNotes + wrapMode: TextEdit.Wrap + width: parent.width + readOnly: true + text: updateDialog.releaseNotes + font.pixelSize: 14 + color: hifi.colors.text + anchors { + left: parent.left + leftMargin: updateDialog.borderWidth + } + } + + } + } } } - - Rectangle { - id: releaseNotes - color: "#CCE8E8E8" - anchors.top: backgroundImage.bottom - anchors.topMargin: 0 - width: backgroundImage.width - 90 - height: releaseNotesContent.height - x: 50 - radius: 10 - - - TextEdit { - id: releaseNotesContent - readOnly: true - font.pixelSize: 13 - width: parent.width - x: 10 - y: 10 - color: "#111111" - text: - "These are the release notes: \n" + - "And some more text about what this includes: \n" + - "These are the release notes: \n" + - "And some more text about what this includes: \n" + - "These are the release notes: \n" + - "And some more text about what this includes: \n"; - } - } - } \ No newline at end of file diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 45c9ea4151..81c7cd2770 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -52,13 +52,7 @@ void DialogsManager::showLoginDialog() { } void DialogsManager::showUpdateDialog() { - qDebug() << "[LEOTEST] We should be showing the update dialog"; - if (!_updateDialog) { - _updateDialog = new UpdateDialog(); - connect(_updateDialog, SIGNAL(closed()), _updateDialog, SLOT(deleteLater())); - _updateDialog->setUpdateAvailableDetails(""); - _updateDialog->show(); - } + UpdateDialog::show(); } void DialogsManager::octreeStatsDetails() { diff --git a/interface/src/ui/UpdateDialog.cpp b/interface/src/ui/UpdateDialog.cpp index 14502f28fc..c5a6234f2c 100644 --- a/interface/src/ui/UpdateDialog.cpp +++ b/interface/src/ui/UpdateDialog.cpp @@ -13,30 +13,30 @@ HIFI_QML_DEF(UpdateDialog) UpdateDialog::UpdateDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) { - + qDebug() << "[LEOTEST] We are creating the dialog"; + 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) + " versions behind"; + _releaseNotes = applicationUpdater.data()->getBuildData()[latestVersion]["releaseNotes"]; + qDebug() << "[LEOTEST] Release time " << applicationUpdater.data()->getBuildData()[latestVersion]["releaseTime"]; + qDebug() << "[LEOTEST] Release notes: " << applicationUpdater.data()->getBuildData()[latestVersion]["releaseNotes"]; } UpdateDialog::~UpdateDialog() { -} -void UpdateDialog::displayDialog() { - setUpdateAvailableDetails(""); - show(); -} - -void UpdateDialog::setUpdateAvailableDetails(const QString& updateAvailableDetails) { - if (updateAvailableDetails == "") { - auto applicationUpdater = DependencyManager::get(); - _updateAvailableDetails = "This is just a test " + QString::number(applicationUpdater.data()->getBuildData().lastKey()); - qDebug() << "[LEOTEST] We are updating the text in the dialog"; - emit updateAvailableDetailsChanged(); - } } QString UpdateDialog::updateAvailableDetails() const { return _updateAvailableDetails; } +QString UpdateDialog::releaseNotes() const { + return _releaseNotes; +} + void UpdateDialog::hide() { ((QQuickItem*)parent())->setEnabled(false); } diff --git a/interface/src/ui/UpdateDialog.h b/interface/src/ui/UpdateDialog.h index 23f2a0faf6..6ba8f0c46b 100644 --- a/interface/src/ui/UpdateDialog.h +++ b/interface/src/ui/UpdateDialog.h @@ -10,31 +10,29 @@ #ifndef __hifi__UpdateDialog__ #define __hifi__UpdateDialog__ + +#include #include class UpdateDialog : public OffscreenQmlDialog { Q_OBJECT HIFI_QML_DECL - Q_PROPERTY(QString updateAvailableDetails READ updateAvailableDetails WRITE setUpdateAvailableDetails NOTIFY updateAvailableDetailsChanged) + Q_PROPERTY(QString updateAvailableDetails READ updateAvailableDetails) + Q_PROPERTY(QString releaseNotes READ releaseNotes) public: UpdateDialog(QQuickItem* parent = nullptr); ~UpdateDialog(); - - void displayDialog(); - void setUpdateAvailableDetails(const QString& updateAvailableDetails); QString updateAvailableDetails() const; - -signals: - void updateAvailableDetailsChanged(); + QString releaseNotes() const; protected: void hide(); - private: QString _updateAvailableDetails; + QString _releaseNotes; protected: Q_INVOKABLE void triggerBuildDownload(const int& buildNumber); diff --git a/libraries/auto-update/src/AutoUpdate.cpp b/libraries/auto-update/src/AutoUpdate.cpp index 093a7b5d86..be52b283c5 100644 --- a/libraries/auto-update/src/AutoUpdate.cpp +++ b/libraries/auto-update/src/AutoUpdate.cpp @@ -140,11 +140,17 @@ void AutoUpdate::downloadUpdateVersion(int version) { emit newVersionIsDownloaded(); } -void AutoUpdate::appendBuildData(int versionNumber, QString downloadURL, QString releaseTime, QString releaseNotes, QString pullRequestNumber) { +void AutoUpdate::appendBuildData(int versionNumber, + QString downloadURL, + QString releaseTime, + QString releaseNotes, + QString pullRequestNumber) { + QMap thisBuildDetails; thisBuildDetails.insert("downloadUrl", downloadURL); thisBuildDetails.insert("releaseTime", releaseTime); thisBuildDetails.insert("releaseNotes", releaseNotes); thisBuildDetails.insert("pullRequestNumber", pullRequestNumber); _builds->insert(versionNumber, thisBuildDetails); + } \ No newline at end of file