[PATCH 2 of 2] Ask the user if software updates should be installed

Wald Commits scm-commit at wald.intevation.org
Wed Apr 23 16:37:42 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1398263837 -7200
# Node ID 1ce835c40eb7479abb8277a8d49967a6192c614c
# Parent  f8bed90083626fbd58fa1b5d5abd57088ee268f6
Ask the user if software updates should be installed.

diff -r f8bed9008362 -r 1ce835c40eb7 ui/mainwindow.cpp
--- 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)
 {
diff -r f8bed9008362 -r 1ce835c40eb7 ui/mainwindow.h
--- 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
      *


More information about the Trustbridge-commits mailing list