From 7b0444263e96c10f7b8cb0c7476b8d5cc7f9567e Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Fri, 2 Jan 2015 15:32:12 -0700 Subject: [PATCH] Quit app before updating Show a message box prompting the user to quit the application before applying the update --- QSimpleUpdater/readme.txt | 8 ++--- .../src/dialogs/download_dialog.cpp | 29 ++++++++++++++++++- QSimpleUpdater/src/dialogs/download_dialog.h | 1 + QSimpleUpdater/src/dialogs/download_dialog.ui | 7 +++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/QSimpleUpdater/readme.txt b/QSimpleUpdater/readme.txt index 4757bfb..fcf1508 100644 --- a/QSimpleUpdater/readme.txt +++ b/QSimpleUpdater/readme.txt @@ -2,7 +2,7 @@ PREFACE -------------- -Many websites today use the HTTPS protocol, which means that you will need SSL in order to communicate with them. If your project needs to access such a webiste (for example GitHub), you will need to carefully read the following information in order to ensure that QSimpleUpdater works with those websites (both in your machine and in the final users' machine). + Many websites today use the HTTPS protocol, which means that you will need SSL in order to communicate with them. If your project needs to access such a webiste (for example GitHub), you will need to carefully read the following information in order to ensure that QSimpleUpdater works with those websites (both in your machine and in the final users' machine). This readme guide is extremely important for any developer wishing to deploy his or her applications under the Windows platform, because the application will depend on the libraries provided by QSimpleUpdater. @@ -10,7 +10,7 @@ This readme guide is extremely important for any developer wishing to deploy his LINUX -------------- - Make sure that you have installed the following libraries in your system: + Make sure that you have installed the following libraries in your system: - lssl - lcrypto @@ -19,13 +19,13 @@ This readme guide is extremely important for any developer wishing to deploy his MAC OSX -------------- -The libraries required by QSimpleUpdater are the same as Linux, however, these libraries are installed by default in most Mac OS X installations. + The libraries required by QSimpleUpdater are the same as Linux, however, these libraries are installed by default in most Mac OS X installations. -------------- WINDOWS -------------- -QSimpleUpdater makes use of the OpenSSL-Win32 project, make sure that you deploy the following DLLs allong your application (the DLLs are provided with the source of QSimpleUpdater): + QSimpleUpdater makes use of the OpenSSL-Win32 project, make sure that you deploy the following DLLs allong your application (the DLLs are provided with the source of QSimpleUpdater): - dependencies/OpenSSL-Win32/bin/libeay32.dll - dependencies/OpenSSL-Win32/bin/ssleay32.dll \ No newline at end of file diff --git a/QSimpleUpdater/src/dialogs/download_dialog.cpp b/QSimpleUpdater/src/dialogs/download_dialog.cpp index 916fd95..3e98067 100644 --- a/QSimpleUpdater/src/dialogs/download_dialog.cpp +++ b/QSimpleUpdater/src/dialogs/download_dialog.cpp @@ -24,6 +24,11 @@ DownloadDialog::DownloadDialog (QWidget *parent) // Connect SIGNALS/SLOTS connect (ui->stopButton, SIGNAL (clicked()), this, SLOT (cancelDownload())); + connect (ui->openButton, SIGNAL (clicked()), this, SLOT (installUpdate())); + + // Configure open button + ui->openButton->setEnabled(false); + ui->openButton->setVisible(false); // Initialize the network access manager m_manager = new QNetworkAccessManager (this); @@ -61,6 +66,28 @@ void DownloadDialog::beginDownload (const QUrl& url) { showNormal(); } +void DownloadDialog::installUpdate(void) { + QMessageBox msg; + msg.setIcon(QMessageBox::Question); + msg.setText("" + + tr("To apply the update(s), you must first quit %1") + .arg(qApp->applicationName()) + + ""); + msg.setInformativeText(tr("Do you want to quit %1 now?").arg(qApp->applicationName())); + msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + + if (msg.exec() == QMessageBox::Yes) { + openDownload(); + qApp->closeAllWindows(); + } + + else { + ui->openButton->setEnabled(true); + ui->openButton->setVisible(true); + ui->timeLabel->setText (tr ("Click the \"Open\" button to apply the update")); + } +} + void DownloadDialog::openDownload(void) { if (!m_path.isEmpty()) { QString url = m_path; @@ -110,7 +137,7 @@ void DownloadDialog::downloadFinished(void) { } file.close(); - openDownload(); + installUpdate(); } } diff --git a/QSimpleUpdater/src/dialogs/download_dialog.h b/QSimpleUpdater/src/dialogs/download_dialog.h index 9a47621..a5d5d0f 100644 --- a/QSimpleUpdater/src/dialogs/download_dialog.h +++ b/QSimpleUpdater/src/dialogs/download_dialog.h @@ -41,6 +41,7 @@ public: private slots: void openDownload(void); + void installUpdate(void); void cancelDownload(void); void downloadFinished(void); void updateProgress (qint64 received, qint64 total); diff --git a/QSimpleUpdater/src/dialogs/download_dialog.ui b/QSimpleUpdater/src/dialogs/download_dialog.ui index 972a641..7350eb6 100644 --- a/QSimpleUpdater/src/dialogs/download_dialog.ui +++ b/QSimpleUpdater/src/dialogs/download_dialog.ui @@ -185,6 +185,13 @@ + + + + Open + + +