KDEUI
knotification.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KNOTIFICATION_H
00021 #define KNOTIFICATION_H
00022
00023 #include <kdeui_export.h>
00024 #include <kcomponentdata.h>
00025
00026 #include <QtGui/QPixmap>
00027 #include <QtCore/QObject>
00028 #include <QtCore/QPair>
00029
00030 class QWidget;
00031 class QDBusError;
00032
00168 class KDEUI_EXPORT KNotification : public QObject
00169 {
00170 Q_OBJECT
00171
00172 public:
00191 typedef QPair<QString,QString> Context;
00192 typedef QList< Context > ContextList;
00193
00194 enum NotificationFlag
00195 {
00202 RaiseWidgetOnActivation=0x01,
00203
00207 CloseOnTimeout=0x00,
00208
00214 Persistent=0x02,
00215
00226 CloseWhenWidgetActivated=0x04,
00230 Persistant = Persistent,
00235 DefaultEvent=0xF000
00236
00237 };
00238
00239 Q_DECLARE_FLAGS(NotificationFlags , NotificationFlag)
00240
00241
00244 enum StandardEvent { Notification , Warning , Error , Catastrophe };
00260 explicit KNotification(const QString & eventId , QWidget *widget=0L, const NotificationFlags &flags=CloseOnTimeout);
00261
00262 ~KNotification();
00263
00273 QWidget *widget() const;
00274
00281 void setWidget(QWidget *widget);
00282
00283
00287 QString eventId() const;
00288
00293 QString text() const ;
00294
00303 void setText(const QString &text);
00304
00309 QPixmap pixmap() const;
00314 void setPixmap(const QPixmap &pix);
00315
00319 QStringList actions() const;
00320
00325 void setActions(const QStringList& actions);
00326
00330 ContextList contexts() const;
00336 void setContexts( const ContextList &contexts);
00341 void addContext( const Context & context);
00347 void addContext( const QString & context_key, const QString & context_value );
00348
00352 NotificationFlags flags() const;
00353
00358 void setFlags(const NotificationFlags &flags);
00359
00364 void setComponentData(const KComponentData &componentData);
00365
00366 Q_SIGNALS:
00370 void activated();
00375 void activated(unsigned int action);
00376
00380 void action1Activated();
00381
00385 void action2Activated();
00386
00390 void action3Activated();
00391
00395 void closed();
00396
00400 void ignored();
00401
00402 public Q_SLOTS:
00407 void activate(unsigned int action=0);
00408
00414 void close();
00415
00420 void raiseWidget();
00421
00430 void ref();
00436 void deref();
00437
00441 void sendEvent();
00442
00447 void update();
00448
00449 private Q_SLOTS:
00450 void slotReceivedId(int);
00451 void slotReceivedIdError(const QDBusError&);
00452
00453 private:
00454 struct Private;
00455 Private *const d;
00456
00457 protected:
00461 virtual bool eventFilter( QObject * watched, QEvent * event );
00462
00463
00464 public:
00488 static KNotification *event(const QString &eventId , const QString &text = QString(),
00489 const QPixmap &pixmap = QPixmap(), QWidget *widget = 0L,
00490 const NotificationFlags &flags = CloseOnTimeout,
00491 const KComponentData &componentData = KComponentData());
00492
00505 static KNotification *event( StandardEvent eventId , const QString& text=QString(),
00506 const QPixmap& pixmap=QPixmap(), QWidget *widget=0L,
00507 const NotificationFlags& flags=CloseOnTimeout);
00508
00515 static void beep( const QString& reason = QString() , QWidget *widget=0L);
00516
00517
00518 using QObject::event;
00519 };
00520
00521 Q_DECLARE_OPERATORS_FOR_FLAGS(KNotification::NotificationFlags)
00522
00523 #endif