diff options
Diffstat (limited to 'libsowatch/notification.h')
-rw-r--r-- | libsowatch/notification.h | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/libsowatch/notification.h b/libsowatch/notification.h index 1af0264..758a8b7 100644 --- a/libsowatch/notification.h +++ b/libsowatch/notification.h @@ -4,6 +4,7 @@ #include <QtCore/QString> #include <QtCore/QDateTime> #include <QtGui/QImage> +#include <QtDeclarative/QtDeclarative> #include "sowatch_global.h" namespace sowatch @@ -13,12 +14,13 @@ class SOWATCH_EXPORT Notification : public QObject { Q_OBJECT Q_ENUMS(Type) - Q_PROPERTY(Type type READ type) - Q_PROPERTY(uint count READ count) - Q_PROPERTY(QDateTime dateTime READ dateTime) - Q_PROPERTY(QString title READ title) - Q_PROPERTY(QString body READ body) - Q_PROPERTY(QImage image READ image) + Q_PROPERTY(Type type READ type CONSTANT) + Q_PROPERTY(uint count READ count NOTIFY countChanged) + Q_PROPERTY(QDateTime dateTime READ dateTime NOTIFY dateTimeChanged) + Q_PROPERTY(QString displayTime READ displayTime NOTIFY displayTimeChanged STORED false) + Q_PROPERTY(QString title READ title NOTIFY titleChanged) + Q_PROPERTY(QString body READ body NOTIFY bodyChanged) + Q_PROPERTY(QImage image READ image NOTIFY imageChanged) public: enum Type { @@ -45,14 +47,30 @@ public: virtual QImage image() const; public slots: + /** Do something on this notification; open the application that caused it, answer, etc. */ virtual void activate() = 0; - virtual void clear() = 0; + /** Dismiss this notification. */ + virtual void dismiss() = 0; signals: + /* For the convenience of QML users */ + void countChanged(); + void dateTimeChanged(); + void displayTimeChanged(); + void titleChanged(); + void bodyChanged(); + void imageChanged(); + + /** Generic "changed" signal if any of the properties changes; can be batched. */ void changed(); - void cleared(); + + /** The notification has been dismissed by the user or via dismiss(). */ + void dismissed(); + /* Provider of this notification object should delete it after dismissal. */ }; } +QML_DECLARE_TYPE(sowatch::Notification) + #endif // SOWATCH_NOTIFICATION_H |