Auto Update checkpoint - dialog is QML and populated with real data

This commit is contained in:
Leonardo Murillo 2015-06-08 13:55:28 -06:00
parent 83b7054138
commit bd85ce1312
5 changed files with 123 additions and 86 deletions

View file

@ -4,69 +4,108 @@ import QtQuick.Controls.Styles 1.3
import "controls" import "controls"
import "styles" import "styles"
UpdateDialog { DialogContainer {
HifiConstants { id: hifi } HifiConstants { id: hifi }
id: updateDialog id: root
objectName: "UpdateDialog" objectName: "UpdateDialog"
implicitWidth: backgroundImage.width implicitWidth: updateDialog.width
implicitHeight: backgroundImage.height + releaseNotes.height implicitHeight: updateDialog.height
x: parent ? parent.width / 2 - width / 2 : 0 x: parent ? parent.width / 2 - width / 2 : 0
y: parent ? parent.height / 2 - height / 2 : 0 y: parent ? parent.height / 2 - height / 2 : 0
Image { UpdateDialog {
id: backgroundImage id: updateDialog
source: "../images/update-available.svg"
width: 576
height: 80
smooth: true
Text { implicitWidth: backgroundRectangle.width
id: updateAvailableTitle implicitHeight: backgroundRectangle.height
text: "Update available"
color: "#000000"
x: 90
y: 17
}
Text { readonly property int inputWidth: 500
id: updateAvailableDetails readonly property int inputHeight: 60
text: updateDialog.updateAvailableDetails readonly property int borderWidth: 30
width: parent.width readonly property int closeMargin: 16
anchors.top: updateAvailableTitle.bottom readonly property int inputSpacing: 16
anchors.topMargin: 3
font.pixelSize: 15 Column {
color: "#545454" id: mainContent
x: 90 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";
}
}
} }

View file

@ -52,13 +52,7 @@ void DialogsManager::showLoginDialog() {
} }
void DialogsManager::showUpdateDialog() { 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() { void DialogsManager::octreeStatsDetails() {

View file

@ -13,30 +13,30 @@
HIFI_QML_DEF(UpdateDialog) HIFI_QML_DEF(UpdateDialog)
UpdateDialog::UpdateDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) { UpdateDialog::UpdateDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) {
qDebug() << "[LEOTEST] We are creating the dialog";
auto applicationUpdater = DependencyManager::get<AutoUpdate>();
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() { UpdateDialog::~UpdateDialog() {
}
void UpdateDialog::displayDialog() {
setUpdateAvailableDetails("");
show();
}
void UpdateDialog::setUpdateAvailableDetails(const QString& updateAvailableDetails) {
if (updateAvailableDetails == "") {
auto applicationUpdater = DependencyManager::get<AutoUpdate>();
_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 { QString UpdateDialog::updateAvailableDetails() const {
return _updateAvailableDetails; return _updateAvailableDetails;
} }
QString UpdateDialog::releaseNotes() const {
return _releaseNotes;
}
void UpdateDialog::hide() { void UpdateDialog::hide() {
((QQuickItem*)parent())->setEnabled(false); ((QQuickItem*)parent())->setEnabled(false);
} }

View file

@ -10,31 +10,29 @@
#ifndef __hifi__UpdateDialog__ #ifndef __hifi__UpdateDialog__
#define __hifi__UpdateDialog__ #define __hifi__UpdateDialog__
#include <QtCore/QCoreApplication>
#include <OffscreenQmlDialog.h> #include <OffscreenQmlDialog.h>
class UpdateDialog : public OffscreenQmlDialog { class UpdateDialog : public OffscreenQmlDialog {
Q_OBJECT Q_OBJECT
HIFI_QML_DECL 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: public:
UpdateDialog(QQuickItem* parent = nullptr); UpdateDialog(QQuickItem* parent = nullptr);
~UpdateDialog(); ~UpdateDialog();
void displayDialog();
void setUpdateAvailableDetails(const QString& updateAvailableDetails);
QString updateAvailableDetails() const; QString updateAvailableDetails() const;
QString releaseNotes() const;
signals:
void updateAvailableDetailsChanged();
protected: protected:
void hide(); void hide();
private: private:
QString _updateAvailableDetails; QString _updateAvailableDetails;
QString _releaseNotes;
protected: protected:
Q_INVOKABLE void triggerBuildDownload(const int& buildNumber); Q_INVOKABLE void triggerBuildDownload(const int& buildNumber);

View file

@ -140,11 +140,17 @@ void AutoUpdate::downloadUpdateVersion(int version) {
emit newVersionIsDownloaded(); 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<QString, QString> thisBuildDetails; QMap<QString, QString> thisBuildDetails;
thisBuildDetails.insert("downloadUrl", downloadURL); thisBuildDetails.insert("downloadUrl", downloadURL);
thisBuildDetails.insert("releaseTime", releaseTime); thisBuildDetails.insert("releaseTime", releaseTime);
thisBuildDetails.insert("releaseNotes", releaseNotes); thisBuildDetails.insert("releaseNotes", releaseNotes);
thisBuildDetails.insert("pullRequestNumber", pullRequestNumber); thisBuildDetails.insert("pullRequestNumber", pullRequestNumber);
_builds->insert(versionNumber, thisBuildDetails); _builds->insert(versionNumber, thisBuildDetails);
} }