From dea80d175756df43683d9d7137680617265a0210 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Fri, 5 Jun 2015 16:17:54 -0600 Subject: [PATCH] Styling update dialog and working towards passing build details from c++ to qml --- interface/resources/qml/UpdateDialog.qml | 73 ++++++++++++++++++++---- interface/src/ui/DialogsManager.cpp | 7 ++- interface/src/ui/DialogsManager.h | 1 + interface/src/ui/UpdateDialog.cpp | 27 +++++++++ interface/src/ui/UpdateDialog.h | 14 ++++- libraries/auto-update/src/AutoUpdate.cpp | 13 +++-- libraries/auto-update/src/AutoUpdate.h | 4 +- 7 files changed, 118 insertions(+), 21 deletions(-) diff --git a/interface/resources/qml/UpdateDialog.qml b/interface/resources/qml/UpdateDialog.qml index 4d564dd56d..884b243682 100644 --- a/interface/resources/qml/UpdateDialog.qml +++ b/interface/resources/qml/UpdateDialog.qml @@ -4,16 +4,67 @@ 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 +Item { + id: updateDialog + implicitWidth: backgroundImage.width + implicitHeight: backgroundImage.height + releaseNotes.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 + + Text { + id: updateAvailableTitle + text: "Update available" + color: "#000000" + x: 90 + y: 17 + } + + Text { + id: updateAvailableDetails + text: updateDialog.updateAvailableDetails + width: parent.width + anchors.top: updateAvailableTitle.bottom + anchors.topMargin: 3 + font.pixelSize: 15 + color: "#545454" + x: 90 + } } + + 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 ebb329fcfd..45c9ea4151 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -53,7 +53,12 @@ void DialogsManager::showLoginDialog() { void DialogsManager::showUpdateDialog() { qDebug() << "[LEOTEST] We should be showing the update dialog"; - UpdateDialog::show(); + if (!_updateDialog) { + _updateDialog = new UpdateDialog(); + connect(_updateDialog, SIGNAL(closed()), _updateDialog, SLOT(deleteLater())); + _updateDialog->setUpdateAvailableDetails(""); + _updateDialog->show(); + } } void DialogsManager::octreeStatsDetails() { diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index f22773a622..7eb716b73c 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -105,6 +105,7 @@ private: QPointer _scriptEditor; QPointer _avatarAppearanceDialog; QPointer _domainConnectionDialog; + QPointer _updateDialog; }; #endif // hifi_DialogsManager_h diff --git a/interface/src/ui/UpdateDialog.cpp b/interface/src/ui/UpdateDialog.cpp index 27fd94fa64..abd7587091 100644 --- a/interface/src/ui/UpdateDialog.cpp +++ b/interface/src/ui/UpdateDialog.cpp @@ -8,6 +8,7 @@ #include "UpdateDialog.h" #include "DependencyManager.h" +#include HIFI_QML_DEF(UpdateDialog) @@ -15,6 +16,32 @@ UpdateDialog::UpdateDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) { } +UpdateDialog::~UpdateDialog() { +} + +void UpdateDialog::displayDialog() { + setUpdateAvailableDetails(""); + show(); +} + +void UpdateDialog::setUpdateAvailableDetails(const QString& updateAvailableDetails) { + if (updateAvailableDetails != _updateAvailableDetails) { + auto applicationUpdater = DependencyManager::get(); + foreach (int key, applicationUpdater.data()->getBuildData().keys()) { + qDebug() << "[LEOTEST] Build number: " << QString::number(key); + } + _updateAvailableDetails = "This is just a test " + QString::number(applicationUpdater.data()->getBuildData().lastKey()); + } +} + +QString UpdateDialog::updateAvailableDetails() const { + return _updateAvailableDetails; +} + void UpdateDialog::hide() { ((QQuickItem*)parent())->setEnabled(false); } + +void UpdateDialog::triggerBuildDownload(const int &buildNumber) { + qDebug() << "[LEOTEST] Triggering download of build number: " << QString::number(buildNumber); +} \ No newline at end of file diff --git a/interface/src/ui/UpdateDialog.h b/interface/src/ui/UpdateDialog.h index bfc69064dd..23f2a0faf6 100644 --- a/interface/src/ui/UpdateDialog.h +++ b/interface/src/ui/UpdateDialog.h @@ -16,16 +16,28 @@ class UpdateDialog : public OffscreenQmlDialog { Q_OBJECT HIFI_QML_DECL + Q_PROPERTY(QString updateAvailableDetails READ updateAvailableDetails WRITE setUpdateAvailableDetails NOTIFY updateAvailableDetailsChanged) + public: UpdateDialog(QQuickItem* parent = nullptr); + ~UpdateDialog(); + + void displayDialog(); + void setUpdateAvailableDetails(const QString& updateAvailableDetails); + QString updateAvailableDetails() const; signals: + void updateAvailableDetailsChanged(); protected: void hide(); -private: +private: + QString _updateAvailableDetails; + +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 2324e69a2e..093a7b5d86 100644 --- a/libraries/auto-update/src/AutoUpdate.cpp +++ b/libraries/auto-update/src/AutoUpdate.cpp @@ -26,6 +26,7 @@ AutoUpdate::AutoUpdate() { _operatingSystem = "ubuntu"; #endif connect(this, SIGNAL(latestVersionDataParsed()), this, SLOT(checkVersionAndNotify())); + _builds = new QMap>; } AutoUpdate::~AutoUpdate() { @@ -114,17 +115,17 @@ void AutoUpdate::parseLatestVersionData() { void AutoUpdate::debugBuildData() { qDebug() << "[LEOTEST] We finished parsing the xml build data"; - foreach (int key, _builds.keys()) { + foreach (int key, _builds->keys()) { qDebug() << "[LEOTEST] Build number: " << QString::number(key); - foreach (QString detailsKey, _builds[key].keys()) { - qDebug() << "[LEOTEST] Key: " << detailsKey << " Value: " << _builds[key][detailsKey]; - } + //foreach (QString detailsKey, _builds[key].keys()) { + // qDebug() << "[LEOTEST] Key: " << detailsKey << " Value: " << _builds[key][detailsKey]; + //} } } void AutoUpdate::checkVersionAndNotify() { qDebug() << "[LEOTEST] We are checking and notifying for updates"; - int latestVersionAvailable = _builds.lastKey(); + int latestVersionAvailable = _builds->lastKey(); if (QCoreApplication::applicationVersion() != "dev" && QCoreApplication::applicationVersion().toInt() < latestVersionAvailable) { emit newVersionIsAvailable(); @@ -145,5 +146,5 @@ void AutoUpdate::appendBuildData(int versionNumber, QString downloadURL, QString thisBuildDetails.insert("releaseTime", releaseTime); thisBuildDetails.insert("releaseNotes", releaseNotes); thisBuildDetails.insert("pullRequestNumber", pullRequestNumber); - _builds.insert(versionNumber, thisBuildDetails); + _builds->insert(versionNumber, thisBuildDetails); } \ No newline at end of file diff --git a/libraries/auto-update/src/AutoUpdate.h b/libraries/auto-update/src/AutoUpdate.h index d77bdc89da..4b32d68c48 100644 --- a/libraries/auto-update/src/AutoUpdate.h +++ b/libraries/auto-update/src/AutoUpdate.h @@ -43,13 +43,13 @@ public: ~AutoUpdate(); void checkForUpdate(); - QMap> getBuildData() { return _builds; } + QMap> &getBuildData() { return *_builds; } public slots: private: // Members - QMap> _builds; + QMap> *_builds; QString _operatingSystem; // Methods