Fix #984 without breaking topic input
[quassel.git] / src / qtui / knotificationbackend.cpp
index e261eac..6cc25a6 100644 (file)
@@ -28,6 +28,7 @@
 #include "client.h"
 #include "icon.h"
 #include "iconloader.h"
+#include "mainwin.h"
 #include "networkmodel.h"
 #include "qtui.h"
 
@@ -36,6 +37,8 @@ KNotificationBackend::KNotificationBackend(QObject *parent)
 {
   connect(QtUi::mainWindow()->systemTray(), SIGNAL(activated(SystemTray::ActivationReason)),
                                             SLOT(notificationActivated(SystemTray::ActivationReason)));
+
+  updateToolTip();
 }
 
 void KNotificationBackend::notify(const Notification &n) {
@@ -62,6 +65,7 @@ void KNotificationBackend::notify(const Notification &n) {
 
   _notifications.append(qMakePair(n.notificationId, QPointer<KNotification>(notification)));
 
+  updateToolTip();
   QtUi::mainWindow()->systemTray()->setAlert(true);
 }
 
@@ -75,11 +79,12 @@ void KNotificationBackend::removeNotificationById(uint notificationId) {
     } else
       ++i;
   }
+  updateToolTip();
 }
 
 void KNotificationBackend::close(uint notificationId) {
   removeNotificationById(notificationId);
-  if(!_notifications.count())
+  //if(!_notifications.count()) // FIXME make configurable
     QtUi::mainWindow()->systemTray()->setAlert(false);
 }
 
@@ -105,6 +110,11 @@ void KNotificationBackend::notificationActivated(uint notificationId) {
   emit activated(notificationId);
 }
 
+void KNotificationBackend::updateToolTip() {
+  QtUi::mainWindow()->systemTray()->setToolTip("Quassel IRC",
+                                               _notifications.count()? tr("%n pending highlights", "", _notifications.count()) : QString());
+}
+
 SettingsPage *KNotificationBackend::createConfigWidget() const {
   return new ConfigWidget();
 }