# HG changeset patch # User Andre Heinecke # Date 1392893809 0 # Node ID 9af6198deb8ea822da1d1ba538eab02210492393 # Parent f4f957c58e0ab8111773b265f9e63b3410f6c87f Add timed trigger for the message diff -r f4f957c58e0a -r 9af6198deb8e ui/mainwindow.cpp --- 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 #include #include +#include + +// 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 } } diff -r f4f957c58e0a -r 9af6198deb8e ui/mainwindow.h --- 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;