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

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • notifications
knotification.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2005-2006 Olivier Goffart <ogoffart at kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 
20 #ifndef KNOTIFICATION_H
21 #define KNOTIFICATION_H
22 
23 #include <kdeui_export.h>
24 #include <kcomponentdata.h>
25 
26 #include <QtGui/QPixmap>
27 #include <QtCore/QObject>
28 #include <QtCore/QPair>
29 
30 class QWidget;
31 class QDBusError;
32 
180 class KDEUI_EXPORT KNotification : public QObject
181 {
182  Q_OBJECT
183 
184 public:
203  typedef QPair<QString,QString> Context;
204  typedef QList< Context > ContextList;
205 
206  enum NotificationFlag
207  {
214  RaiseWidgetOnActivation=0x01,
215 
219  CloseOnTimeout=0x00,
220 
226  Persistent=0x02,
227 
238  CloseWhenWidgetActivated=0x04,
242  Persistant = Persistent,
247  DefaultEvent=0xF000
248 
249  };
250 
251  Q_DECLARE_FLAGS(NotificationFlags , NotificationFlag)
252 
253 
256  enum StandardEvent { Notification , Warning , Error , Catastrophe };
257 
273  explicit KNotification(const QString & eventId , QWidget *widget=0L, const NotificationFlags &flags=CloseOnTimeout);
274 
292  // KDE5: Clean up this mess
293  // Only this constructor should stay with saner argument order and
294  // defaults. Because of binary and source compatibility issues it has to
295  // stay this way for now. The second argument CANNOT have a default
296  // argument. if someone needs a widget associated with the notification he
297  // should use setWidget after creating the object (or some xyz_cast magic)
298  explicit KNotification(const QString & eventId , const NotificationFlags &flags, QObject *parent = NULL );
299 
300  ~KNotification();
301 
311  QWidget *widget() const;
312 
319  void setWidget(QWidget *widget);
320 
321 
325  QString eventId() const;
326 
332  QString title() const;
333 
341  void setTitle(const QString &title);
342 
347  QString text() const ;
348 
357  void setText(const QString &text);
358 
363  QPixmap pixmap() const;
368  void setPixmap(const QPixmap &pix);
369 
373  QStringList actions() const;
374 
379  void setActions(const QStringList& actions);
380 
384  ContextList contexts() const;
390  void setContexts( const ContextList &contexts);
395  void addContext( const Context & context);
401  void addContext( const QString & context_key, const QString & context_value );
402 
406  NotificationFlags flags() const;
407 
412  void setFlags(const NotificationFlags &flags);
413 
418  void setComponentData(const KComponentData &componentData);
419 
420  Q_SIGNALS:
424  void activated();
429  void activated(unsigned int action);
430 
434  void action1Activated();
435 
439  void action2Activated();
440 
444  void action3Activated();
445 
449  void closed();
450 
454  void ignored();
455 
456 public Q_SLOTS:
461  void activate(unsigned int action=0);
462 
468  void close();
469 
474  void raiseWidget();
475 
484  void ref();
490  void deref();
491 
495  void sendEvent();
496 
501  void update();
502 
503 private Q_SLOTS:
504  void slotReceivedId(int);
505  void slotReceivedIdError(const QDBusError&);
506 
507 private:
508  struct Private;
509  Private *const d;
510 
511 protected:
515  virtual bool eventFilter( QObject * watched, QEvent * event );
516 
517 
518 public:
544  static KNotification *event(const QString &eventId , const QString &title, const QString &text,
545  const QPixmap &pixmap = QPixmap(), QWidget *widget = 0L,
546  const NotificationFlags &flags = CloseOnTimeout,
547  const KComponentData &componentData = KComponentData());
548 
563  static KNotification *event(const QString &eventId , const QString &text = QString(),
564  const QPixmap &pixmap = QPixmap(), QWidget *widget = 0L,
565  const NotificationFlags &flags = CloseOnTimeout,
566  const KComponentData &componentData = KComponentData());
567 
581  static KNotification *event( StandardEvent eventId , const QString& text=QString(),
582  const QPixmap& pixmap=QPixmap(), QWidget *widget=0L,
583  const NotificationFlags& flags=CloseOnTimeout);
584 
600  static KNotification *event( StandardEvent eventId , const QString& title, const QString& text,
601  const QPixmap& pixmap=QPixmap(), QWidget *widget=0L,
602  const NotificationFlags& flags=CloseOnTimeout);
603 
610  static void beep( const QString& reason = QString() , QWidget *widget=0L);
611 
612  //prevent warning
613  using QObject::event;
614 };
615 
616 Q_DECLARE_OPERATORS_FOR_FLAGS(KNotification::NotificationFlags)
617 
618 #endif
QEvent
QWidget
ref
void ref()
QObject::event
virtual bool event(QEvent *e)
deref
void deref()
KNotification::Context
QPair< QString, QString > Context
Sometimes the user may want different notifications for the same event, depending the source of the e...
Definition: knotification.h:203
QObject
Error
QObject::eventFilter
virtual bool eventFilter(QObject *watched, QEvent *event)
QString
QList< Context >
QStringList
QPair
QPixmap
KNotification::ContextList
QList< Context > ContextList
Definition: knotification.h:204
KNotification::StandardEvent
StandardEvent
default events you can use in the event function
Definition: knotification.h:256
KNotification
KNotification is used to notify the user of an event.
Definition: knotification.h:180
KNotification::NotificationFlag
NotificationFlag
Definition: knotification.h:206
kdeui_export.h
KCrash::setFlags
void setFlags(CrashFlags flags)
Set options to determine how the default crash handler should behave.
kcomponentdata.h
KNotification::Warning
Definition: knotification.h:256
KComponentData
KStandardAction::close
KAction * close(const QObject *recvr, const char *slot, QObject *parent)
Close the current document.
Definition: kstandardaction.cpp:269
QDBusError
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • 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

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal