Permalink
Browse files

fixed #324 Add a notification queue

  • Loading branch information...
1 parent 8f4a0de commit 10d5f316838b8896101300846f00adc5b77d2337 @pvanek pvanek committed Aug 6, 2012
@@ -184,6 +184,21 @@ void Notification::setValues(const QString &application,
setMinimumHeight(qMax(rect().height(), childrenRect().height()));
}
+QString Notification::application() const
+{
+ return appLabel->text();
+}
+
+QString Notification::summary() const
+{
+ return summaryLabel->text();
+}
+
+QString Notification::body() const
+{
+ return bodyLabel->text();
+}
+
void Notification::closeButton_clicked()
{
if (m_timer)
@@ -64,6 +64,10 @@ class Notification : public QWidget, public Ui::Notification
const QString &icon, int timeout,
const QStringList& actions, const QVariantMap& hints);
+ QString application() const;
+ QString summary() const;
+ QString body() const;
+
signals:
//! the server set timeout passed. Notification should close itself.
void timeout();
@@ -77,13 +77,37 @@ void NotificationLayout::addNotification(uint id, const QString &application,
else
{
Notification *n = new Notification(application, summary, body, icon, timeout, actions, hints, this);
- connect(n, SIGNAL(timeout()), this, SLOT(removeNotificationTimeout()));
- connect(n, SIGNAL(userCanceled()), this, SLOT(removeNotificationUser()));
- connect(n, SIGNAL(actionTriggered(QString)),
- this, SLOT(notificationActionCalled(QString)));
- m_notifications[id] = n;
- m_layout->addWidget(n);
- n->show();
+
+ // NOTE: it's hard to use == operator for Notification* in QList...
+ bool found = false;
+ QHashIterator<uint, Notification*> it(m_notifications);
+ while (it.hasNext())
+ {
+ it.next();
+ if (it.value()->application() == application
+ && it.value()->summary() == summary
+ && it.value()->body() == body)
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (found)
+ {
+ qDebug() << "Notification app" << application << "summary" << summary << "is already registered but this request is not an update. Broken app?";
+ delete n;
+ }
+ else
+ {
+ connect(n, SIGNAL(timeout()), this, SLOT(removeNotificationTimeout()));
+ connect(n, SIGNAL(userCanceled()), this, SLOT(removeNotificationUser()));
+ connect(n, SIGNAL(actionTriggered(QString)),
+ this, SLOT(notificationActionCalled(QString)));
+ m_notifications[id] = n;
+ m_layout->addWidget(n);
+ n->show();
+ }
}
emit notificationAvailable();
@@ -0,0 +1,12 @@
+#!/bin/sh
+#
+# reqrired: notify-send app installed (part of libnotify, or libnotify-tools)
+#
+
+
+# basic notifications
+notify-send -u low -t 3000 --icon="document-open" "simple notification" "expires in 3s. No action there" &
+notify-send -u normal -t 4000 --icon="document-close" "simple notification" "expires in 4s. No action there" &
+notify-send -u low -t 3000 --icon="document-open" "simple notification" "expires in 3s. No action there" &
+notify-send -u low -t 3000 --icon="document-open" "simple notification" "expires in 3s. No action there" &
+

0 comments on commit 10d5f31

Please sign in to comment.