diff ui/mainwindow.cpp @ 1334:5c6294c201c2

(issue170) Add delay for update checking
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 16 Oct 2014 09:53:35 +0200
parents dd3eefda8503
children 64f812a63de6
line wrap: on
line diff
--- a/ui/mainwindow.cpp	Wed Oct 15 15:40:27 2014 +0200
+++ b/ui/mainwindow.cpp	Thu Oct 16 09:53:35 2014 +0200
@@ -51,6 +51,12 @@
 // something to say
 #define NAG_INTERVAL_MINUTES 70
 
+/** @def The interval in which the update check in tray mode is placed
+ *
+ * The interval should be given in minutes. The first update check will
+ * be placed randomly inside this interval. */
+#define FIRST_CHECK_INTERVAL_MINUTES 180
+
 #define DATETIME_FORMAT "d. MMM yyyy HH:mm"
 
 #ifndef APPNAME
@@ -117,7 +123,13 @@
     connect(mMessageTimer, SIGNAL(timeout()), this, SLOT(showMessage()));
     mMessageTimer->setInterval(NAG_INTERVAL_MINUTES * 60 * 1000);
     mMessageTimer->start();
-    checkUpdates();
+    if (trayMode) {
+        /* Place the first update in a random interval in the first 3h
+         * after start. */
+        QTimer::singleShot(qrand() % (FIRST_CHECK_INTERVAL_MINUTES * 60 * 1000), this, SLOT(checkUpdates()));
+    } else {
+        checkUpdates();
+    }
     loadUnselectedCertificates();
     loadCertificateList();
 

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