X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fknotificationbackend.cpp;h=8cc58a9a0a0c3ab5bac69b9b8d03efa200f68992;hb=9f461bad6c890d3fe92d89ebf1b6a3f313d7e8ef;hp=baf0f1507e4dabd20ab4db2a523bd088b9bd0d2e;hpb=b324a124e384bd8c9f54d97c5b5d6a5cc50fd91b;p=quassel.git diff --git a/src/qtui/knotificationbackend.cpp b/src/qtui/knotificationbackend.cpp index baf0f150..8cc58a9a 100644 --- a/src/qtui/knotificationbackend.cpp +++ b/src/qtui/knotificationbackend.cpp @@ -1,5 +1,5 @@ /*************************************************************************** -* Copyright (C) 2005-08 by the Quassel Project * +* Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,7 @@ #include #include +#include #include "knotificationbackend.h" @@ -30,25 +31,42 @@ #include "iconloader.h" #include "networkmodel.h" #include "qtui.h" +#include "systemtray.h" KNotificationBackend::KNotificationBackend(QObject *parent) : AbstractNotificationBackend(parent) { } void KNotificationBackend::notify(const Notification &n) { - //QString title = Client::networkModel()->networkName(n.bufferId) + " - " + Client::networkModel()->bufferName(n.bufferId); - QString message = QString("<%1> %2").arg(n.sender, n.message); + QString message = QString("<%1> %2").arg(n.sender, Qt::escape(n.message)); KNotification *notification = KNotification::event("Highlight", message, DesktopIcon("dialog-information"), QtUi::mainWindow(), KNotification::Persistent|KNotification::RaiseWidgetOnActivation|KNotification::CloseWhenWidgetActivated); - connect(notification, SIGNAL(activated()), SLOT(notificationActivated())); + connect(notification, SIGNAL(activated(uint)), SLOT(notificationActivated())); + connect(notification, SIGNAL(closed()), SLOT(notificationClosed())); + notification->setActions(QStringList("View")); + _notificationIds[notification] = n.notificationId; + + QtUi::mainWindow()->systemTray()->setAlert(true); } void KNotificationBackend::close(uint notificationId) { Q_UNUSED(notificationId); + QtUi::mainWindow()->systemTray()->setAlert(false); } void KNotificationBackend::notificationActivated() { - emit activated(); + uint id = 0; + KNotification *n = qobject_cast(sender()); + if(n && _notificationIds.contains(n)) + id = _notificationIds.value(n); + + emit activated(id); +} + +void KNotificationBackend::notificationClosed() { + KNotification *n = qobject_cast(sender()); + if(n && _notificationIds.contains(n)) + _notificationIds.remove(n); } SettingsPage *KNotificationBackend::createConfigWidget() const {