Integrate DesktopNotification into system tray/status notifier
[quassel.git] / src / qtui / legacysystemtray.cpp
index 18186f2..0c6a1e3 100644 (file)
@@ -27,7 +27,8 @@
 LegacySystemTray::LegacySystemTray(QWidget *parent)
   : SystemTray(parent),
   _blinkState(false),
-  _isVisible(true)
+  _isVisible(true),
+  _lastMessageId(0)
 {
 #ifndef HAVE_KDE
   _trayIcon = new QSystemTrayIcon(associatedWidget());
@@ -42,7 +43,7 @@ LegacySystemTray::LegacySystemTray(QWidget *parent)
                      SLOT(on_activated(QSystemTrayIcon::ActivationReason)));
 #endif
   connect(_trayIcon, SIGNAL(messageClicked()),
-                     SIGNAL(messageClicked()));
+                     SLOT(on_messageClicked()));
 
   _blinkTimer.setInterval(500);
   _blinkTimer.setSingleShot(false);
@@ -131,8 +132,24 @@ void LegacySystemTray::on_activated(QSystemTrayIcon::ActivationReason reason) {
   activate((SystemTray::ActivationReason)reason);
 }
 
-void LegacySystemTray::showMessage(const QString &title, const QString &message, SystemTray::MessageIcon icon, int millisecondsTimeoutHint) {
-  _trayIcon->showMessage(title, message, (QSystemTrayIcon::MessageIcon)icon, millisecondsTimeoutHint);
+void LegacySystemTray::on_messageClicked() {
+  emit messageClicked(_lastMessageId);
+}
+
+void LegacySystemTray::showMessage(const QString &title, const QString &message, SystemTray::MessageIcon icon, int msTimeout, uint id) {
+  // fancy stuff later: show messages in order
+  // for now, we just show the last message
+  _lastMessageId = id;
+  _trayIcon->showMessage(title, message, (QSystemTrayIcon::MessageIcon)icon, msTimeout);
+}
+
+void LegacySystemTray::closeMessage(uint notificationId) {
+  Q_UNUSED(notificationId)
+
+  // there really seems to be no sane way to close the bubble... :(
+#ifdef Q_WS_X11
+  showMessage("", "", NoIcon, 1);
+#endif
 }
 
 #endif /* QT_NO_SYSTEMTRAYICON */