summaryrefslogtreecommitdiff
path: root/libsowatch/notification.h
blob: e20f8971535ac8257d802c0beae544ad221bf31f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef SOWATCH_NOTIFICATION_H
#define SOWATCH_NOTIFICATION_H

#include <QtCore/QString>
#include <QtCore/QDateTime>
#include <QtGui/QImage>
#include <QtDeclarative/QtDeclarative>
#include "sowatch_global.h"

namespace sowatch
{

class SOWATCH_EXPORT Notification : public QObject
{
	Q_OBJECT
	Q_ENUMS(Type Priority)
	Q_PROPERTY(Type type READ type CONSTANT)
	Q_PROPERTY(Priority priority READ priority NOTIFY priorityChanged)
	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 {
		OtherNotification = 0,
		CallNotification,
		MissedCallNotification,
		SmsNotification,
		MmsNotification,
		ImNotification,
		EmailNotification,
		CalendarNotification,
		WeatherNotification,
		TypeCount
	};

	enum Priority {
		Silent,
		Normal,
		Urgent
	};

	explicit Notification(QObject *parent = 0);
	virtual ~Notification();

	virtual Type type() const = 0;
	virtual Priority priority() const;
	virtual uint count() const = 0;
	virtual QDateTime dateTime() const = 0;
	virtual QString displayTime() const;
	virtual QString title() const = 0;
	virtual QString body() const = 0;
	virtual QImage image() const;

public slots:
	/** Do something on this notification; open the application that caused it, answer, etc. */
	virtual void activate() = 0;
	/** Dismiss this notification. */
	virtual void dismiss() = 0;

signals:
	void priorityChanged();
	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();

	/** 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)
QML_DECLARE_TYPE(sowatch::Notification::Type)
QML_DECLARE_TYPE(sowatch::Notification::Priority)

#endif // SOWATCH_NOTIFICATION_H