changeset 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 f8bed9008362
children 091ad56c2715
files ui/mainwindow.cpp ui/mainwindow.h
diffstat 2 files changed, 25 insertions(+), 5 deletions(-) [+]
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)
 {
--- a/ui/mainwindow.h	Wed Apr 23 16:34:41 2014 +0200
+++ b/ui/mainwindow.h	Wed Apr 23 16:37:17 2014 +0200
@@ -63,7 +63,7 @@
 private slots:
     void showMessage();
     void iconActivated(QSystemTrayIcon::ActivationReason reason);
-    void checkUpdates();
+    void checkUpdates(bool downloadSW = false);
     void handleNewList(const QString& fileName, const QDateTime& modDate);
     void handleNewSW(const QString& fileName, const QDateTime& modDate);
     void downloaderError(const QString &message, SSLConnection::ErrorCode error);
@@ -78,6 +78,7 @@
     void installerError(const QString& errMsg);
     void installerSuccess();
     void installCerts();
+    void newSWAvailable(const QString& fileName, const QDateTime& modDate);
 
     /** @brief saves the currently unselected certificates
      *

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