[PATCH 2 of 3] Delay the tray icon after the download

Wald Commits scm-commit at wald.intevation.org
Thu Aug 28 11:26:56 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1409217955 -7200
# Node ID 423e31ac656eab7a5ad56180a1e9e5d6737c2ca2
# Parent  64c0e15935c8ef8ed7284fef360cd9913cd95baa
Delay the tray icon after the download

    Otherwise it would show up for a very short time if you close
    the application after download.

diff -r 64c0e15935c8 -r 423e31ac656e ui/mainwindow.cpp
--- a/ui/mainwindow.cpp	Thu Aug 28 10:44:08 2014 +0200
+++ b/ui/mainwindow.cpp	Thu Aug 28 11:25:55 2014 +0200
@@ -157,7 +157,15 @@
     if (mCurMessage.isEmpty()) {
         return;
     }
-    if (mCurState == NewSoftwareAvailable || !isVisible()) {
+
+    if (!mTrayIcon->isVisible() && !mTrayIcon->isAlternative()) {
+        mTrayIcon->show();
+        /* When the message is shown before the tray icon is fully visble
+         * and becoming visible may be delayed on some desktop environments
+         * the message will pop up somehere on the screen and not over
+         * the trayicon. So we delay here.*/
+        QTimer::singleShot(2000, this, SLOT(showMessage()));
+    } else if (mCurState == NewSoftwareAvailable || !isVisible()) {
         mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage,
                                QSystemTrayIcon::Information, 10000);
         mMessageTimer->start(); // Restart the timer so that we don't spam
@@ -446,6 +454,7 @@
     /* 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();
     setState(TransferError);
 }
@@ -471,7 +480,6 @@
 
     mTrayIcon->setIcon(trayImg);
     setWindowIcon(trayImg);
-    mTrayIcon->show();
     mTrayIcon->setToolTip(tr("TrustBridge"));
 
     connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));


More information about the Trustbridge-commits mailing list