Mercurial > trustbridge
changeset 19:9af6198deb8e
Add timed trigger for the message
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 20 Feb 2014 10:56:49 +0000 |
parents | f4f957c58e0a |
children | fec1a610d43f |
files | ui/mainwindow.cpp ui/mainwindow.h |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ui/mainwindow.cpp Wed Feb 19 15:41:14 2014 +0000 +++ b/ui/mainwindow.cpp Thu Feb 20 10:56:49 2014 +0000 @@ -8,6 +8,11 @@ #include <QMenu> #include <QApplication> #include <QFile> +#include <QTimer> + +// The amount of time in minutes stay silent if we have +// something to say +#define NAG_INTERVAL_MINUTES 2 #include "certificatelist.h" #include "downloader.h" @@ -18,6 +23,11 @@ connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); + + mMessageTimer = new QTimer(this); + connect(mMessageTimer, SIGNAL(timeout()), this, SLOT(showMessage())); + mMessageTimer->setInterval(NAG_INTERVAL_MINUTES * 60 * 1000); + mMessageTimer->start(); } void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) @@ -40,6 +50,7 @@ if (!mCurMessage.isEmpty()) { mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, QSystemTrayIcon::Information, 5000); + mMessageTimer->start(); // Restart the timer so that we don't spam } }
--- a/ui/mainwindow.h Wed Feb 19 15:41:14 2014 +0000 +++ b/ui/mainwindow.h Thu Feb 20 10:56:49 2014 +0000 @@ -8,6 +8,7 @@ #include "downloader.h" class QMenu; class QAction; +class QTimer; class MainWindow : public QDialog { @@ -49,7 +50,7 @@ QSettings mSettings; QSystemTrayIcon *mTrayIcon; - + QTimer *mMessageTimer; QMenu *mTrayMenu; QAction *mCheckUpdates; QAction *mQuitAction;