changeset 1061:db831a204a6b

(issue38) Show error message as messagebox if the window is visible
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 10 Sep 2014 11:05:34 +0200
parents 317ee9dc4684
children 515345358b71
files ui/mainwindow.cpp ui/mainwindow.h
diffstat 2 files changed, 24 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Tue Sep 09 18:49:02 2014 +0200
+++ b/ui/mainwindow.cpp	Wed Sep 10 11:05:34 2014 +0200
@@ -475,9 +475,13 @@
 {
     /* TODO logging and handle error according to a plan */
     syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData());
-    mCurMessage = message;
-    mTrayIcon->show();
-    showMessage();
+    if (!isVisible()) {
+        mCurMessage = message;
+        mTrayIcon->show();
+        showMessage();
+    } else {
+        showErrorMessage(tr("Failed to check for updates:") + "\n"  + message);
+    }
     setState(TransferError);
 }
 
@@ -1465,3 +1469,8 @@
     free (inst_dir);
     return;
 }
+
+void MainWindow::showErrorMessage(const QString &msg)
+{
+    QMessageBox::warning(this, tr("TrustBridge error"), msg);
+}
--- a/ui/mainwindow.h	Tue Sep 09 18:49:02 2014 +0200
+++ b/ui/mainwindow.h	Wed Sep 10 11:05:34 2014 +0200
@@ -169,6 +169,13 @@
      * the application. */
     void installNewSW(const QString& fileName, const QDateTime& modDate);
 
+    /** @brief show an error message
+     *
+     * This is a wrapper around QMessageBox to allow for central
+     * styling of error messages.
+     */
+    void showErrorMessage(const QString &msg);
+
 signals:
     /** @brief emits the changecount as a string when it changes */
     void changesChanged(const QString& cnt);
@@ -217,11 +224,14 @@
      * (accessible via button panel) */
     QWidget *createRemoveWidget();
 
-    /* Are we running in tray mode ?*/
+    /** @brief true if the software is running in tray mode*/
     const bool mTrayMode;
-    /* The message currently shown at intervals */
+
+    /** @brief The currently shown message */
     QString mCurMessage;
+    /** @brief The version the Software thinks is installed */
     QString mInstalledSWVersion;
+    /** @brief The certificate list the Software thinks is installed */
     QString mInstalledListVersion;
 
     QSettings mSettings;

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