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
00180 class KDEUI_EXPORT KNotification : public QObject
00181 {
00182 Q_OBJECT
00183
00184 public:
00203 typedef QPair<QString,QString> Context;
00204 typedef QList< Context > ContextList;
00205
00206 enum NotificationFlag
00207 {
00214 RaiseWidgetOnActivation=0x01,
00215
00219 CloseOnTimeout=0x00,
00220
00226 Persistent=0x02,
00227
00238 CloseWhenWidgetActivated=0x04,
00242 Persistant = Persistent,
00247 DefaultEvent=0xF000
00248
00249 };
00250
00251 Q_DECLARE_FLAGS(NotificationFlags , NotificationFlag)
00252
00253
00256 enum StandardEvent { Notification , Warning , Error , Catastrophe };
00257
00273 explicit KNotification(const QString & eventId , QWidget *widget=0L, const NotificationFlags &flags=CloseOnTimeout);
00274
00292
00293
00294
00295
00296
00297
00298 explicit KNotification(const QString & eventId , const NotificationFlags &flags, QObject *parent = NULL );
00299
00300 ~KNotification();
00301
00311 QWidget *widget() const;
00312
00319 void setWidget(QWidget *widget);
00320
00321
00325 QString eventId() const;
00326
00332 QString title() const;
00333
00341 void setTitle(const QString &title);
00342
00347 QString text() const ;
00348
00357 void setText(const QString &text);
00358
00363 QPixmap pixmap() const;
00368 void setPixmap(const QPixmap &pix);
00369
00373 QStringList actions() const;
00374
00379 void setActions(const QStringList& actions);
00380
00384 ContextList contexts() const;
00390 void setContexts( const ContextList &contexts);
00395 void addContext( const Context & context);
00401 void addContext( const QString & context_key, const QString & context_value );
00402
00406 NotificationFlags flags() const;
00407
00412 void setFlags(const NotificationFlags &flags);
00413
00418 void setComponentData(const KComponentData &componentData);
00419
00420 Q_SIGNALS:
00424 void activated();
00429 void activated(unsigned int action);
00430
00434 void action1Activated();
00435
00439 void action2Activated();
00440
00444 void action3Activated();
00445
00449 void closed();
00450
00454 void ignored();
00455
00456 public Q_SLOTS:
00461 void activate(unsigned int action=0);
00462
00468 void close();
00469
00474 void raiseWidget();
00475
00484 void ref();
00490 void deref();
00491
00495 void sendEvent();
00496
00501 void update();
00502
00503 private Q_SLOTS:
00504 void slotReceivedId(int);
00505 void slotReceivedIdError(const QDBusError&);
00506
00507 private:
00508 struct Private;
00509 Private *const d;
00510
00511 protected:
00515 virtual bool eventFilter( QObject * watched, QEvent * event );
00516
00517
00518 public:
00544 static KNotification *event(const QString &eventId , const QString &title, const QString &text,
00545 const QPixmap &pixmap = QPixmap(), QWidget *widget = 0L,
00546 const NotificationFlags &flags = CloseOnTimeout,
00547 const KComponentData &componentData = KComponentData());
00548
00563 static KNotification *event(const QString &eventId , const QString &text = QString(),
00564 const QPixmap &pixmap = QPixmap(), QWidget *widget = 0L,
00565 const NotificationFlags &flags = CloseOnTimeout,
00566 const KComponentData &componentData = KComponentData());
00567
00581 static KNotification *event( StandardEvent eventId , const QString& text=QString(),
00582 const QPixmap& pixmap=QPixmap(), QWidget *widget=0L,
00583 const NotificationFlags& flags=CloseOnTimeout);
00584
00600 static KNotification *event( StandardEvent eventId , const QString& title, const QString& text,
00601 const QPixmap& pixmap=QPixmap(), QWidget *widget=0L,
00602 const NotificationFlags& flags=CloseOnTimeout);
00603
00610 static void beep( const QString& reason = QString() , QWidget *widget=0L);
00611
00612
00613 using QObject::event;
00614 };
00615
00616 Q_DECLARE_OPERATORS_FOR_FLAGS(KNotification::NotificationFlags)
00617
00618 #endif