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
00176 class KDEUI_EXPORT KNotification : public QObject
00177 {
00178 Q_OBJECT
00179
00180 public:
00199 typedef QPair<QString,QString> Context;
00200 typedef QList< Context > ContextList;
00201
00202 enum NotificationFlag
00203 {
00210 RaiseWidgetOnActivation=0x01,
00211
00215 CloseOnTimeout=0x00,
00216
00222 Persistent=0x02,
00223
00234 CloseWhenWidgetActivated=0x04,
00238 Persistant = Persistent,
00243 DefaultEvent=0xF000
00244
00245 };
00246
00247 Q_DECLARE_FLAGS(NotificationFlags , NotificationFlag)
00248
00249
00252 enum StandardEvent { Notification , Warning , Error , Catastrophe };
00268 explicit KNotification(const QString & eventId , QWidget *widget=0L, const NotificationFlags &flags=CloseOnTimeout);
00269
00270 ~KNotification();
00271
00281 QWidget *widget() const;
00282
00289 void setWidget(QWidget *widget);
00290
00291
00295 QString eventId() const;
00296
00302 QString title() const;
00303
00311 void setTitle(const QString &title);
00312
00317 QString text() const ;
00318
00327 void setText(const QString &text);
00328
00333 QPixmap pixmap() const;
00338 void setPixmap(const QPixmap &pix);
00339
00343 QStringList actions() const;
00344
00349 void setActions(const QStringList& actions);
00350
00354 ContextList contexts() const;
00360 void setContexts( const ContextList &contexts);
00365 void addContext( const Context & context);
00371 void addContext( const QString & context_key, const QString & context_value );
00372
00376 NotificationFlags flags() const;
00377
00382 void setFlags(const NotificationFlags &flags);
00383
00388 void setComponentData(const KComponentData &componentData);
00389
00390 Q_SIGNALS:
00394 void activated();
00399 void activated(unsigned int action);
00400
00404 void action1Activated();
00405
00409 void action2Activated();
00410
00414 void action3Activated();
00415
00419 void closed();
00420
00424 void ignored();
00425
00426 public Q_SLOTS:
00431 void activate(unsigned int action=0);
00432
00438 void close();
00439
00444 void raiseWidget();
00445
00454 void ref();
00460 void deref();
00461
00465 void sendEvent();
00466
00471 void update();
00472
00473 private Q_SLOTS:
00474 void slotReceivedId(int);
00475 void slotReceivedIdError(const QDBusError&);
00476
00477 private:
00478 struct Private;
00479 Private *const d;
00480
00481 protected:
00485 virtual bool eventFilter( QObject * watched, QEvent * event );
00486
00487
00488 public:
00512 static KNotification *event(const QString &eventId , const QString &text = QString(),
00513 const QPixmap &pixmap = QPixmap(), QWidget *widget = 0L,
00514 const NotificationFlags &flags = CloseOnTimeout,
00515 const KComponentData &componentData = KComponentData());
00516
00529 static KNotification *event( StandardEvent eventId , const QString& text=QString(),
00530 const QPixmap& pixmap=QPixmap(), QWidget *widget=0L,
00531 const NotificationFlags& flags=CloseOnTimeout);
00532
00539 static void beep( const QString& reason = QString() , QWidget *widget=0L);
00540
00541
00542 using QObject::event;
00543 };
00544
00545 Q_DECLARE_OPERATORS_FOR_FLAGS(KNotification::NotificationFlags)
00546
00547 #endif