some UI changes for usability
[makneto-zunavac1.git] / src / libnotify-qt / Notification.h
blobdd53fe92f838fce423b4ea2c798bf8e553bab5a0
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
21 #include <QList>
22 #include <QObject>
23 #include <QStringList>
24 #include <QVariantMap>
26 enum ServerInfo
28 SERVER_INFO_NAME = 0,
29 SERVER_INFO_VENDOR,
30 SERVER_INFO_VERSION
33 enum NotificationUrgency
35 NOTIFICATION_URGENCY_LOW,
36 NOTIFICATION_URGENCY_NORMAL,
37 NOTIFICATION_URGENCY_CRITICAL
40 class QDBusInterface;
41 class OrgFreedesktopNotificationsInterface;
43 namespace org
45 namespace freedesktop
47 typedef OrgFreedesktopNotificationsInterface Notifications;
51 class Q_DECL_EXPORT Notification : public QObject
53 Q_OBJECT
55 typedef QList<Notification *> NotificationList;
57 public:
58 static bool init(const QString & appName);
59 static void uninit();
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);
68 ~Notification();
70 bool show();
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);
88 void clearHints();
90 void addAction(const QString & actionKey, const QString & label);
91 void clearActions();
93 bool close();
95 bool autoDelete() const;
96 void setAutoDelete(bool autoDelete);
98 private slots:
99 void onNotificationClosed(quint32 id, quint32 reason);
100 void onActionInvoked(quint32 id, const QString & actionKey);
102 private:
103 static void addNotification(Notification * n);
104 static void removeNotification(Notification * n);
106 private:
107 static bool s_isInitted;
108 static QString s_appName;
109 static org::freedesktop::Notifications * s_notifications;
111 quint32 m_id;
112 QString m_summary;
113 QString m_body;
114 QString m_iconName;
115 qint32 m_timeout;
116 QStringList m_actions;
117 QVariantMap m_hints;
119 bool m_autoDelete;
121 signals:
122 void closed(quint32 reason);
123 void actionInvoked(const QString & actionKey);
126 #endif // NOTIFICATION_H