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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
/* This file is part of the KDE libraries
Copyright (C) 2005 Olivier Goffart <ogoffart @ kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KNOTIFICATION_H
#define KNOTIFICATION_H
#include <tqpixmap.h>
#include <tqobject.h>
#include <tqstringlist.h>
#include "kopete_export.h"
class TQWidget;
namespace Kopete { class MetaContact; }
/**
* KNotification is used to notify some event to the user.
*
* It covers severals kind of notifications
*
* @li Interface feedback events:
* For notifying the user that he/she just performed an operation, like maximizing a
* window. This allows us to play sounds when a dialog appears.
* This is an instant notification. It ends automatically after a small timeout
*
* @li complex notifications:
* Notify when one received a new message, or when something important happened
* the user has to know. This notification has a start and a end. It start when
* the event actually occurs, and finish when the message is acknowledged.
*
*
* use the static function event() to fire an event
*
* the returned KNotification pointer may be used to connect signals or slots
*
* @author Olivier Goffart <ogoffart @ kde.org>
*/
class KOPETE_EXPORT KNotification : public QObject
{
Q_OBJECT
public:
enum NotificationFlags
{
/**
* When the notification is activated, raise the notification's widget.
*
* This will change the desktop, raise the window, and switch to the tab.
*/
RaiseWidgetOnActivation=0x01,
/**
* The notification will be automatically closed after a timeout.
*/
CloseOnTimeout=0x02,
/**
* The notification will be automatically closed if the widget() becomes
* activated.
*
* If the widget is already activated when the notification occurs, the
* notification will be closed after a small timeout.
*/
CloseWhenWidgetActivated=0x03
};
~KNotification();
/**
* @brief the widget associated to the notification
*
* If the widget is destroyed, the notification will be automatically canceled.
* If the widget is activated, the notificaiton will be automatically closed if the flags said that
*
* When the notification is activated, the widget might be raised.
* Depending of the configuration, the taskbar entry of the window containing the widget may blink.
*/
TQWidget *widget();
signals:
/**
* Emit only when the default activation has occured
*/
void activated();
/**
* Emit when an action has been activated.
* @param action will be 0 is the default aciton was activated, or any actiton id
*/
void activated(unsigned int action);
/**
* Emit when the notification is closed. Both if it's activated or just ignored
*/
void closed();
/**
* The notification has been ignored
*/
void ignored();
public slots:
/**
* @brief Active the action specified action
* If the action is zero, then the default action is activated
*/
void activate(unsigned int action=0);
/**
* close the notification without activate it.
*
* This will delete the notification
*/
void close();
/**
* @brief Raise the widget.
* This will change the desktop, activate the window, and the tab if needed.
*/
void raiseWidget();
private:
struct Private;
Private *d;
KNotification(TQObject *parent=0L);
/**
* recursive function that raise the widget. @p w
*
* @see raiseWidget()
*/
static void raiseWidget(TQWidget *w);
bool m_linkClicked;
private slots:
void notifyByMessagebox();
void notifyByPassivePopup(const TQPixmap &pix);
void notifyByExecute(const TQString &command, const TQString& event,const TQString& fromApp, const TQString& text, int winId, int eventId);
void slotPopupLinkClicked(const TQString &);
public:
/**
* @brief emit an event
*
* A popup may be showed, a sound may be played, depending the config.
*
* return a KNotification . You may use that pointer to connect some signals or slot.
* the pointer is automatically deleted when the event is closed.
*
* Make sure you use one of the CloseOnTimeOut or CloseWhenWidgetActivated, if not,
* you have to close yourself the notification.
*
* @note the text is shown in a TQLabel, you should make sure to escape the html is needed.
*
* @param eventId is the name of the event
* @param text is the text of the notification to show in the popup.
* @param pixmap is a picture which may be shown in the popup.
* @param widget is a widget where the notification reports to
* @param actions is a list of action texts.
* @param flags is a bitmask of NotificationsFlags
*/
static KNotification *event( const TQString& eventId , const TQString& text=TQString::null,
const TQPixmap& pixmap=TQPixmap(), TQWidget *widget=0L,
const TQStringList &actions=TQStringList(), unsigned int flags=CloseOnTimeout);
/**
* @brief emit a custom event
*
* @param text is the text of the notification to show in the popup.
* @param pixmap is a picture which may be shown in the popup
* @param widget is a widget where the notification raports to
* @param actions is a list of actions text.
* @param present The presentation method of the event
* @param level The error message level
* @param sound The sound to play if selected with @p present
* @param file The log file to append the message to if selected with @p parent
* @param commandLine the command line to run if selected with @p parent
* @param flags Indicates the way in which the notification should be handled
*/
static KNotification *userEvent( const TQString& text, const TQPixmap& pixmap,
TQWidget *widget, TQStringList actions,int present, int level,
const TQString &sound, const TQString &file,
const TQString &commandLine, unsigned int flags);
/**
* @todo find a proper way to do context-dependent notifications
*/
static KNotification *event( Kopete::MetaContact *mc, const TQString& eventId , const TQString& text=TQString::null,
const TQPixmap& pixmap=TQPixmap(), TQWidget *widget=0L,
const TQStringList &actions=TQStringList(),unsigned int flags=CloseOnTimeout);
};
#endif
|