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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/*
* NotifyWidget.h
*
* Copyright (C) 2021 Emanoil Kotsev <[email protected]>
*
*
* This file is part of kdbusnotification.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef SRC_DAEMON_NOTIFYWIDGET_H_
#define SRC_DAEMON_NOTIFYWIDGET_H_
#include <tqlabel.h>
#include <tqtextedit.h>
#include <tqpixmap.h>
#include <tqdbusvariant.h>
class NotificationsService;
class NotifyWidget: public TQLabel
{
TQ_OBJECT
public:
NotifyWidget(TQWidget *parent=0, const char *name=0, NotificationsService *ns=0, TQ_INT32 id=0 );
virtual ~NotifyWidget();
enum UrgencyLevel { Low, Normal, Critical };
void setAutoMask(bool b);
bool setIcon(const TQString& icon);
/**
* The actions send a request message back to the notification client when invoked. This functionality may not be implemented by the notification server, conforming clients should check if it is available before using it (see the GetCapabilities message in Protocol). An implementation is free to ignore any requested by the client. As an example one possible rendering of actions would be as buttons in the notification popup.
Actions are sent over as a list of pairs. Each even element in the list (starting at index 0) represents the identifier for the action. Each odd element in the list is the localized string that will be displayed to the user.
The default action (usually invoked by clicking the notification) should have a key named "default". The name can be anything, though implementations are free not to display it.
*/
void setActions(const TQStringList& actions);
/**
* Hints are a way to provide extra data to a notification server that the server may be able to make use of.
* Hints
* Category
* Notifications can optionally have a type indicator. Although neither client or nor server must support this, some may choose to. Those servers implementing categories may use them to intelligently display the notification in a certain way, or group notifications of similar types.
Categories are in class.specific form. class specifies the generic type of notification, and specific specifies the more specific type of notification.
* Urgency
* Notifications have an urgency level associated with them. This defines the importance of the notification.
* Developers must use their own judgement when deciding the urgency of a notification.
* Typically, if the majority of programs are using the same level for a specific type of urgency,
* other applications should follow them.
* For low and normal urgencies, server implementations may display the notifications how they choose.
* They should, however, have a sane expiration timeout dependent on the urgency level.
*
* Critical notifications should not automatically expire, as they are things that the user will
* most likely want to know about. They should only be closed when the user dismisses them,
* for example, by clicking on the notification.
* Persistence
* The server supports persistence of notifications. Notifications will be retained until they are
* acknowledged or removed by the user or recalled by the sender. The presence of this capability
* allows clients to depend on the server to ensure a notification is seen and eliminate the need
* for the client to display a reminding function (such as a status icon) of its own.
*
* image
*/
void setCategory(const TQString&);
void setPersistence(bool);
void setImage(const TQString&);
void setImageData(const TQValueList<TQT_DBusData>&);
void setSoundFile(const TQString&);
void setSoundName(const TQString&);
void setSuppressSound(bool);
void setTransient(bool);
void setUrgency(TQ_UINT16);
void setSenderPid(TQ_UINT64);
/**
* The timeout time in milliseconds since the display of the notification at which the notification should automatically close.
If -1, the notification's expiration time is dependent on the notification server's settings, and may vary for the type of notification.
If 0, the notification never expires.
*/
void setTimeout(TQ_INT32 t);
protected:
void mousePressEvent( TQMouseEvent *);
private slots:
void slotTimeout();
void slotFadeAway();
/**
* DBus signals
* 1. org.freedesktop.Notifications.NotificationClosed is implemented
* 2. org.freedesktop.Notifications.ActionInvoked is not implemented (see mActions)
* 3. org.freedesktop.Notifications.ActivationToken is not implemented (see mActions)
*/
private:
NotificationsService *notificationService;
TQString mName;
TQ_INT32 mId;
TQString mIcon;
TQStringList mActions; // not implemented
TQString mCategory; // not implemented
TQTimer *mTimer;
TQ_UINT16 mUrgency;
TQPixmap mImageData;
TQString mSoundFile;
TQString mSoundName;
bool mPersistence;
bool mSuppressSound;
bool mTransient;
TQ_UINT64 mSenderPid;
};
#endif /* SRC_DAEMON_NOTIFYWIDGET_H_ */
|