Quit app before updating
Show a message box prompting the user to quit the application before applying the update
This commit is contained in:
parent
34e331b2ac
commit
7b0444263e
@ -24,6 +24,11 @@ DownloadDialog::DownloadDialog (QWidget *parent)
|
|||||||
|
|
||||||
// Connect SIGNALS/SLOTS
|
// Connect SIGNALS/SLOTS
|
||||||
connect (ui->stopButton, SIGNAL (clicked()), this, SLOT (cancelDownload()));
|
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
|
// Initialize the network access manager
|
||||||
m_manager = new QNetworkAccessManager (this);
|
m_manager = new QNetworkAccessManager (this);
|
||||||
@ -61,6 +66,28 @@ void DownloadDialog::beginDownload (const QUrl& url) {
|
|||||||
showNormal();
|
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) {
|
void DownloadDialog::openDownload(void) {
|
||||||
if (!m_path.isEmpty()) {
|
if (!m_path.isEmpty()) {
|
||||||
QString url = m_path;
|
QString url = m_path;
|
||||||
@ -110,7 +137,7 @@ void DownloadDialog::downloadFinished(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
openDownload();
|
installUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void openDownload(void);
|
void openDownload(void);
|
||||||
|
void installUpdate(void);
|
||||||
void cancelDownload(void);
|
void cancelDownload(void);
|
||||||
void downloadFinished(void);
|
void downloadFinished(void);
|
||||||
void updateProgress (qint64 received, qint64 total);
|
void updateProgress (qint64 received, qint64 total);
|
||||||
|
@ -185,6 +185,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="openButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="stopButton">
|
<widget class="QPushButton" name="stopButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user