comparison ui/mainwindow.cpp @ 19:9af6198deb8e

Add timed trigger for the message
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 20 Feb 2014 10:56:49 +0000
parents c12825a651ed
children 62cd56cea09b
comparison
equal deleted inserted replaced
18:f4f957c58e0a 19:9af6198deb8e
6 #include <QAction> 6 #include <QAction>
7 #include <QDialog> 7 #include <QDialog>
8 #include <QMenu> 8 #include <QMenu>
9 #include <QApplication> 9 #include <QApplication>
10 #include <QFile> 10 #include <QFile>
11 #include <QTimer>
12
13 // The amount of time in minutes stay silent if we have
14 // something to say
15 #define NAG_INTERVAL_MINUTES 2
11 16
12 #include "certificatelist.h" 17 #include "certificatelist.h"
13 #include "downloader.h" 18 #include "downloader.h"
14 19
15 MainWindow::MainWindow() { 20 MainWindow::MainWindow() {
16 createActions(); 21 createActions();
17 createTrayIcon(); 22 createTrayIcon();
18 23
19 connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), 24 connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
20 this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); 25 this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
26
27 mMessageTimer = new QTimer(this);
28 connect(mMessageTimer, SIGNAL(timeout()), this, SLOT(showMessage()));
29 mMessageTimer->setInterval(NAG_INTERVAL_MINUTES * 60 * 1000);
30 mMessageTimer->start();
21 } 31 }
22 32
23 void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) 33 void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
24 { 34 {
25 switch (reason) { 35 switch (reason) {
38 void MainWindow::showMessage() 48 void MainWindow::showMessage()
39 { 49 {
40 if (!mCurMessage.isEmpty()) { 50 if (!mCurMessage.isEmpty()) {
41 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, 51 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage,
42 QSystemTrayIcon::Information, 5000); 52 QSystemTrayIcon::Information, 5000);
53 mMessageTimer->start(); // Restart the timer so that we don't spam
43 } 54 }
44 } 55 }
45 56
46 /** @brief check the integrity of available files. 57 /** @brief check the integrity of available files.
47 * 58 *

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