1 /* libnotify-qt - library for sending notifications implemented in Qt
2 * Copyright (C) 2010-2011 Vojtech Drbohlav <vojta.d@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef NOTIFICATION_H
19 #define NOTIFICATION_H
23 #include <QStringList>
24 #include <QVariantMap>
33 enum NotificationUrgency
35 NOTIFICATION_URGENCY_LOW
,
36 NOTIFICATION_URGENCY_NORMAL
,
37 NOTIFICATION_URGENCY_CRITICAL
41 class OrgFreedesktopNotificationsInterface
;
47 typedef OrgFreedesktopNotificationsInterface Notifications
;
51 class Q_DECL_EXPORT Notification
: public QObject
55 typedef QList
<Notification
*> NotificationList
;
58 static bool init(const QString
& appName
);
60 static bool isInitted();
62 static const QString
& getAppName();
63 static QStringList
getServerCaps();
64 static bool getServerInfo(QString
& name
, QString
& vendor
, QString
& version
);
66 Notification(const QString
& summary
, const QString
& body
= QString(),
67 const QString
& iconName
= QString(), QObject
* parent
= 0);
72 void setSummary(const QString
& summary
);
73 void setBody(const QString
& body
);
74 void setIconName(const QString
& iconName
);
75 void setTimeout(qint32 timeout
);
77 void setUrgency(NotificationUrgency urgency
);
78 void setCategory(const QString
& category
);
79 //void setIconFromPixmap(const QPixmap & pixmap);
80 void setLocation(qint32 x
, qint32 y
);
82 void setHint(const QString
& key
, const QVariant
& value
);
83 void setHintInt32(const QString
& key
, qint32 value
);
84 void setHintDouble(const QString
& key
, double value
);
85 void setHintString(const QString
& key
, const QString
& value
);
86 void setHintByte(const QString
& key
, quint8 value
);
87 void setHintByteArray(const QString
& key
, const QByteArray
& value
);
90 void addAction(const QString
& actionKey
, const QString
& label
);
95 bool autoDelete() const;
96 void setAutoDelete(bool autoDelete
);
99 void onNotificationClosed(quint32 id
, quint32 reason
);
100 void onActionInvoked(quint32 id
, const QString
& actionKey
);
103 static void addNotification(Notification
* n
);
104 static void removeNotification(Notification
* n
);
107 static bool s_isInitted
;
108 static QString s_appName
;
109 static org::freedesktop::Notifications
* s_notifications
;
116 QStringList m_actions
;
122 void closed(quint32 reason
);
123 void actionInvoked(const QString
& actionKey
);
126 #endif // NOTIFICATION_H