[PATCH 1 of 2] (issue38) Show error message as messagebox if the window is visible

Wald Commits scm-commit at wald.intevation.org
Wed Sep 10 11:06:54 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1410339934 -7200
# Node ID db831a204a6b3d40d61ed49226e9404858da68d1
# Parent  317ee9dc4684b2df73807b2f11212e374e6a75d7
(issue38) Show error message as messagebox if the window is visible

diff -r 317ee9dc4684 -r db831a204a6b ui/mainwindow.cpp
--- 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);
+}
diff -r 317ee9dc4684 -r db831a204a6b ui/mainwindow.h
--- 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;


More information about the Trustbridge-commits mailing list