2011-09-03 20:52:54 +02:00
|
|
|
#ifndef NOTIFICATOR_H
|
|
|
|
#define NOTIFICATOR_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QIcon>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QSystemTrayIcon;
|
2011-09-24 11:56:33 +02:00
|
|
|
#ifdef USE_DBUS
|
2011-09-03 20:52:54 +02:00
|
|
|
class QDBusInterface;
|
|
|
|
#endif
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
// Cross-platform desktop notification client
|
|
|
|
class Notificator: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
// Create a new notificator
|
|
|
|
// Ownership of trayIcon is not transferred to this object
|
|
|
|
Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0);
|
|
|
|
~Notificator();
|
|
|
|
|
|
|
|
// Message class
|
|
|
|
enum Class
|
|
|
|
{
|
|
|
|
Information,
|
|
|
|
Warning,
|
|
|
|
Critical,
|
|
|
|
};
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
/* Show notification message.
|
|
|
|
*
|
|
|
|
* cls: general message class
|
|
|
|
* title: title shown with message
|
|
|
|
* text: message content
|
|
|
|
* icon: optional icon to show with message
|
|
|
|
* millisTimeout: notification timeout in milliseconds (default 10 seconds)
|
|
|
|
*/
|
|
|
|
void notify(Class cls, const QString &title, const QString &text,
|
|
|
|
const QIcon &icon = QIcon(), int millisTimeout = 10000);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QWidget *parent;
|
|
|
|
enum Mode {
|
|
|
|
None,
|
|
|
|
Freedesktop, // Use DBus org.freedesktop.Notifications
|
|
|
|
QSystemTray, // Use QSystemTray::showMessage
|
2011-10-07 13:21:45 +02:00
|
|
|
Growl // Use the Growl notification system (Mac only)
|
2011-09-03 20:52:54 +02:00
|
|
|
};
|
|
|
|
QString programName;
|
|
|
|
Mode mode;
|
|
|
|
QSystemTrayIcon *trayIcon;
|
2011-09-24 11:56:33 +02:00
|
|
|
#ifdef USE_DBUS
|
2011-09-03 20:52:54 +02:00
|
|
|
QDBusInterface *interface;
|
|
|
|
|
|
|
|
void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
|
|
|
|
#endif
|
|
|
|
void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
|
2011-10-07 13:21:45 +02:00
|
|
|
#ifdef Q_WS_MAC
|
|
|
|
void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon);
|
|
|
|
#endif
|
2011-09-03 20:52:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // NOTIFICATOR_H
|