From 664a1a7677eb1402f415eea5e9606d2fdc15636b Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Thu, 9 Jan 2014 20:12:39 -0600 Subject: [PATCH] Checkpoint --- interface/src/Application.cpp | 4 ++-- interface/src/Application.h | 2 +- interface/src/ui/UpdateDialog.cpp | 31 ++++++++++++++++++++++++------- interface/src/ui/UpdateDialog.h | 4 +++- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0727c8658f..b0b26be540 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4588,7 +4588,7 @@ void Application::parseVersionXml(QNetworkReply *reply) { if (xml.name() == "Version") { xml.readNext(); - _latestVersion = xml.text().toString(); + *_latestVersion = xml.text().toString(); } } @@ -4601,6 +4601,6 @@ void Application::parseVersionXml(QNetworkReply *reply) { _downloadLink = new QUrl("http://www.google.com"); UpdateDialog *_updateDialog = new UpdateDialog(_glWidget, _releaseNotes, _downloadLink, _latestVersion, applicationVersion()); - _updateDialog->show(); + _updateDialog->exec(); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 99873d4b57..6461bf3925 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -521,7 +521,7 @@ private: FileLogger* _logger; - QString _latestVersion; + QString *_latestVersion; QString _operatingSystem; }; diff --git a/interface/src/ui/UpdateDialog.cpp b/interface/src/ui/UpdateDialog.cpp index d9543f318b..710c4e7166 100644 --- a/interface/src/ui/UpdateDialog.cpp +++ b/interface/src/ui/UpdateDialog.cpp @@ -15,19 +15,27 @@ const int buttonWidth = 120; const int buttonHeight = 40; -const int dialogWidth = 500; +const int buttonMargin = 15; +const int leftStartingPosition = 345; +const int dialogWidth = 750; const int dialogHeigth = 300; const QString dialogTitle = "Update Required"; -UpdateDialog::UpdateDialog(QWidget *parent, QString releaseNotes, QUrl *downloadURL, QString latestVersion, QString currentVersion) : QDialog(parent, Qt::Dialog) { +UpdateDialog::UpdateDialog(QWidget *parent, QString releaseNotes, QUrl *downloadURL, QString *latestVersion, QString currentVersion) : QDialog(parent, Qt::Dialog) { + + _downloadURL = downloadURL; + _latestVersion = latestVersion; const QString updateRequired = QString("You are currently running build %1, the latest build released is %2.\n \ Please download and install the most recent release to access the latest \ - features and bug fixes.").arg(currentVersion, latestVersion); + features and bug fixes.").arg(currentVersion, *latestVersion); + int leftPosition = leftStartingPosition; setWindowTitle(dialogTitle); + //setWindowFlags(Qt::WindowTitleHint); setModal(true); + resize(dialogWidth, dialogHeigth); QFile styleSheet("resources/styles/update_dialog.qss"); if (styleSheet.open(QIODevice::ReadOnly)) { setStyleSheet(styleSheet.readAll()); @@ -40,26 +48,35 @@ UpdateDialog::UpdateDialog(QWidget *parent, QString releaseNotes, QUrl *download _downloadButton = new QPushButton("Download", this); _downloadButton->setObjectName("downloadButton"); + _downloadButton->setGeometry(leftPosition, buttonMargin, buttonWidth, buttonHeight); + leftPosition += buttonWidth; + _skipButton = new QPushButton("Skip Version", this); _skipButton->setObjectName("skipButton"); + _skipButton->setGeometry(leftPosition, buttonMargin, buttonWidth, buttonHeight); + leftPosition += buttonWidth; + _closeButton = new QPushButton("Close", this); _closeButton->setObjectName("closeButton"); + _closeButton->setGeometry(leftPosition, buttonMargin, buttonWidth, buttonHeight); _titleBackground = new QFrame(); connect(_downloadButton, SIGNAL(released()), this, SLOT(handleDownload())); - connect(_skipButton, SIGNAL(released()), this, SLOT(handleDownload())); + connect(_skipButton, SIGNAL(released()), this, SLOT(handleSkip())); connect(_closeButton, SIGNAL(released()), this, SLOT(handleClose())); } void UpdateDialog::handleDownload() { - qDebug("download clicked"); + QDesktopServices::openUrl((*_downloadURL)); + close(); } void UpdateDialog::handleSkip() { - qDebug("skip clicked"); + QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation); + fileName.append(QString("/hifi.skipversion")); } void UpdateDialog::handleClose() { - qDebug("close clicked"); + close(); } \ No newline at end of file diff --git a/interface/src/ui/UpdateDialog.h b/interface/src/ui/UpdateDialog.h index bd374afb5b..b50b38bf72 100644 --- a/interface/src/ui/UpdateDialog.h +++ b/interface/src/ui/UpdateDialog.h @@ -20,7 +20,7 @@ class UpdateDialog : public QDialog { Q_OBJECT public: - UpdateDialog(QWidget*, QString releaseNotes, QUrl *downloadURL, QString latestVersion, QString currentVersion); + UpdateDialog(QWidget*, QString releaseNotes, QUrl *downloadURL, QString *latestVersion, QString currentVersion); private: QLabel *_updateRequired; @@ -29,6 +29,8 @@ private: QPushButton *_skipButton; QPushButton *_closeButton; QFrame *_titleBackground; + QUrl *_downloadURL; + QString *_latestVersion; private slots: void handleDownload();