diff ui/mainwindow.cpp @ 461:1ce835c40eb7

Ask the user if software updates should be installed.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 23 Apr 2014 16:37:17 +0200
parents 37a97621b466
children a8d56a2846a8
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Wed Apr 23 16:34:41 2014 +0200
+++ b/ui/mainwindow.cpp	Wed Apr 23 16:37:17 2014 +0200
@@ -181,7 +181,7 @@
     showMessage();
 }
 
-void MainWindow::checkUpdates()
+void MainWindow::checkUpdates(bool downloadSW)
 {
     verifyAvailableData();
 
@@ -205,18 +205,37 @@
 // TODO                                       swInstalledLastMod,
                                             listInstalledLastMod,
                                             swResource,
-                                            listResource);
+                                            listResource,
+                                            downloadSW);
 
     connect(downloader, SIGNAL(newListAvailable(const QString&, const QDateTime&)),
             this, SLOT(handleNewList(const QString&, const QDateTime&)));
-    connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
-            this, SLOT(handleNewSW(const QString&, const QDateTime&)));
+    if (!downloadSW) {
+        connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
+                this, SLOT(newSWAvailable(const QString&, const QDateTime&)));
+    }
+    else {
+        connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
+                this, SLOT(handleNewSW(const QString&, const QDateTime&)));
+    }
     connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater()));
     connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
             this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
     downloader->start();
 }
 
+void MainWindow::newSWAvailable(const QString &fileName, const QDateTime &date) {
+    QMessageBox msgBox;
+    msgBox.setIcon(QMessageBox::Information);
+    msgBox.setText("<h3>" + tr("New Software version is available.") + "</h3>");
+    msgBox.setInformativeText(tr("Do you want to install the new Version?"));
+    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
+    msgBox.setDefaultButton(QMessageBox::Yes);
+    int selection = msgBox.exec();
+    if (selection == QMessageBox::Yes) {
+        checkUpdates(true);
+    }
+}
 
 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error)
 {

http://wald.intevation.org/projects/trustbridge/