• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KDEUI

knotification.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2005-2006 Olivier Goffart <ogoffart at kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
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     // KDE5: Clean up this mess
00293     // Only this constructor should stay with saner argument order and
00294     // defaults. Because of binary and source compatibility issues it has to
00295     // stay this way for now. The second argument CANNOT have a default
00296     // argument. if someone needs a widget associated with the notification he
00297     // should use setWidget after creating the object (or some xyz_cast magic)
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     //prevent warning
00613     using QObject::event;
00614 };
00615 
00616 Q_DECLARE_OPERATORS_FOR_FLAGS(KNotification::NotificationFlags)
00617 
00618 #endif

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal