Save/restore active bufferview
[quassel.git] / src / qtui / knotificationbackend.cpp
index d3939df..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);
 }
 
@@ -93,15 +98,21 @@ void KNotificationBackend::notificationActivated() {
 }
 
 void KNotificationBackend::notificationActivated(SystemTray::ActivationReason reason) {
-  if(reason == SystemTray::Trigger && _notifications.count()) {
-    notificationActivated(_notifications.first().first); // oldest one
+  if(reason == SystemTray::Trigger) {
+    if( _notifications.count())
+      notificationActivated(_notifications.first().first); // oldest one
+    else
+      GraphicalUi::toggleMainWidget();
   }
 }
 
 void KNotificationBackend::notificationActivated(uint notificationId) {
-  QtUi::mainWindow()->systemTray()->setInhibitActivation();
   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 {