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
00164 class KDEUI_EXPORT KNotification : public QObject
00165 {
00166 Q_OBJECT
00167
00168 public:
00187 typedef QPair<QString,QString> Context;
00188 typedef QList< Context > ContextList;
00189
00190 enum NotificationFlag
00191 {
00198 RaiseWidgetOnActivation=0x01,
00199
00203 CloseOnTimeout=0x00,
00204
00210 Persistent=0x02,
00211
00222 CloseWhenWidgetActivated=0x04,
00226 Persistant = Persistent,
00231 DefaultEvent=0xF000
00232
00233 };
00234
00235 Q_DECLARE_FLAGS(NotificationFlags , NotificationFlag)
00236
00237
00240 enum StandardEvent { Notification , Warning , Error , Catastrophe };
00256 explicit KNotification(const QString & eventId , QWidget *widget=0L, const NotificationFlags &flags=CloseOnTimeout);
00257
00258 ~KNotification();
00259
00269 QWidget *widget() const;
00270
00277 void setWidget(QWidget *widget);
00278
00279
00283 QString eventId() const;
00284
00289 QString text() const ;
00290
00299 void setText(const QString &text);
00300
00305 QPixmap pixmap() const;
00310 void setPixmap(const QPixmap &pix);
00311
00315 QStringList actions() const;
00316
00321 void setActions(const QStringList& actions);
00322
00326 ContextList contexts() const;
00332 void setContexts( const ContextList &contexts);
00337 void addContext( const Context & context);
00343 void addContext( const QString & context_key, const QString & context_value );
00344
00348 NotificationFlags flags() const;
00349
00354 void setFlags(const NotificationFlags &flags);
00355
00360 void setComponentData(const KComponentData &componentData);
00361
00362 Q_SIGNALS:
00366 void activated();
00371 void activated(unsigned int action);
00372
00376 void action1Activated();
00377
00381 void action2Activated();
00382
00386 void action3Activated();
00387
00391 void closed();
00392
00396 void ignored();
00397
00398 public Q_SLOTS:
00403 void activate(unsigned int action=0);
00404
00410 void close();
00411
00416 void raiseWidget();
00417
00426 void ref();
00432 void deref();
00433
00437 void sendEvent();
00438
00443 void update();
00444
00445 private Q_SLOTS:
00446 void slotReceivedId(int);
00447 void slotReceivedIdError(const QDBusError&);
00448
00449 private:
00450 struct Private;
00451 Private *const d;
00452
00453 protected:
00457 virtual bool eventFilter( QObject * watched, QEvent * event );
00458
00459
00460 public:
00484 static KNotification *event(const QString &eventId , const QString &text = QString(),
00485 const QPixmap &pixmap = QPixmap(), QWidget *widget = 0L,
00486 const NotificationFlags &flags = CloseOnTimeout,
00487 const KComponentData &componentData = KComponentData());
00488
00501 static KNotification *event( StandardEvent eventId , const QString& text=QString(),
00502 const QPixmap& pixmap=QPixmap(), QWidget *widget=0L,
00503 const NotificationFlags& flags=CloseOnTimeout);
00504
00511 static void beep( const QString& reason = QString() , QWidget *widget=0L);
00512
00513
00514 using QObject::event;
00515 };
00516
00517 Q_DECLARE_OPERATORS_FOR_FLAGS(KNotification::NotificationFlags)
00518
00519 #endif