Quit app before updating

Show a message box prompting the user to quit the application before
applying the update
This commit is contained in:
Alex Spataru 2015-01-02 15:32:12 -07:00
parent 34e331b2ac
commit 7b0444263e
4 changed files with 40 additions and 5 deletions

View File

@ -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.
@ -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

View File

@ -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("<b>" +
tr("To apply the update(s), you must first quit %1")
.arg(qApp->applicationName()) +
"</b>");
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();
}
}

View File

@ -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);

View File

@ -185,6 +185,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="openButton">
<property name="text">
<string>Open</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="stopButton">
<property name="text">