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

KDEUI

  • 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
30class QWidget;
31class QDBusError;
32
180class KDEUI_EXPORT KNotification : public QObject
181{
182 Q_OBJECT
183
184public:
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
456public 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
503private Q_SLOTS:
504 void slotReceivedId(int);
505 void slotReceivedIdError(const QDBusError&);
506
507private:
508 struct Private;
509 Private *const d;
510
511protected:
515 virtual bool eventFilter( QObject * watched, QEvent * event );
516
517
518public:
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
616Q_DECLARE_OPERATORS_FOR_FLAGS(KNotification::NotificationFlags)
617
618#endif
KComponentData
KNotification
KNotification is used to notify the user of an event.
Definition: knotification.h:181
KNotification::closed
void closed()
Emitted when the notification is closed.
KNotification::activated
void activated(unsigned int action)
Emit when an action has been activated.
KNotification::action3Activated
void action3Activated()
This is an overloaded member function, provided for convenience. It differs from the above function o...
KNotification::action2Activated
void action2Activated()
This is an overloaded member function, provided for convenience. It differs from the above function o...
KNotification::action1Activated
void action1Activated()
Convenience signal that is emitted when the first action is activated.
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::activated
void activated()
Emit only when the default activation has occurred.
KNotification::ignored
void ignored()
The notification has been ignored.
KNotification::NotificationFlag
NotificationFlag
Definition: knotification.h:207
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
QList< Context >
QObject
QPair
QWidget
kcomponentdata.h
kdeui_export.h
deref
void deref()
ref
void ref()
Warning
Warning
Error
Error
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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