KNotification
#include <KNotification>

Public Types | |
typedef QPair< QString, QString > | Context |
typedef QList< Context > | ContextList |
enum | NotificationFlag { RaiseWidgetOnActivation = 0x01, CloseOnTimeout = 0x00, Persistent = 0x02, CloseWhenWidgetActivated = 0x04, LoopSound = 0x08, SkipGrouping = 0x10, DefaultEvent = 0xF000 } |
typedef QFlags< NotificationFlag > | NotificationFlags |
enum | StandardEvent { Notification, Warning, Error, Catastrophe } |
enum | Urgency { DefaultUrgency = -1, LowUrgency = 10, NormalUrgency = 50, HighUrgency = 70, CriticalUrgency = 90 } |
Properties | |
QStringList | actions |
bool | autoDelete |
QString | componentName |
QString | defaultAction |
QString | eventId |
NotificationFlags | flags |
QVariantMap | hints |
QString | iconName |
QString | text |
QString | title |
Urgency | urgency |
QList< QUrl > | urls |
QString | xdgActivationToken |
![]() | |
objectName | |
Signals | |
void | action1Activated () |
void | action2Activated () |
void | action3Activated () |
void | actionsChanged () |
void | activated () |
void | activated (unsigned int action) |
void | autoDeleteChanged () |
void | closed () |
void | componentNameChanged () |
void | defaultActionChanged () |
void | defaultActivated () |
void | eventIdChanged () |
void | flagsChanged () |
void | hintsChanged () |
void | iconNameChanged () |
void | ignored () |
void | textChanged () |
void | titleChanged () |
void | urgencyChanged () |
void | urlsChanged () |
void | xdgActivationTokenChanged () |
Public Slots | |
void | activate (unsigned int action=0) |
void | close () |
void | deref () |
QVariantMap | hints () const |
void | raiseWidget () |
void | ref () |
void | sendEvent () |
Q_INVOKABLE void | setHint (const QString &hint, const QVariant &value) |
void | setHints (const QVariantMap &hints) |
void | update () |
Public Member Functions | |
KNotification (const QString &eventId) | |
KNotification (const QString &eventId, const NotificationFlags &flags, QObject *parent=nullptr) | |
KNotification (const QString &eventId, QWidget *widget, const NotificationFlags &flags=CloseOnTimeout) | |
QStringList | actions () const |
void | addContext (const Context &context) |
void | addContext (const QString &context_key, const QString &context_value) |
QString | appName () const |
QString | componentName () const |
ContextList | contexts () const |
QString | defaultAction () const |
virtual bool | event (QEvent *e) |
QString | eventId () const |
NotificationFlags | flags () const |
QString | iconName () const |
int | id () |
bool | isAutoDelete () const |
QPixmap | pixmap () const |
KNotificationReplyAction * | replyAction () const |
void | setActions (const QStringList &actions) |
void | setAutoDelete (bool autoDelete) |
void | setComponentName (const QString &componentName) |
void | setContexts (const ContextList &contexts) |
void | setDefaultAction (const QString &defaultAction) |
void | setEventId (const QString &eventId) |
void | setFlags (const NotificationFlags &flags) |
void | setIconName (const QString &icon) |
void | setPixmap (const QPixmap &pix) |
void | setReplyAction (std::unique_ptr< KNotificationReplyAction > replyAction) |
void | setText (const QString &text) |
void | setTitle (const QString &title) |
void | setUrgency (Urgency urgency) |
void | setUrls (const QList< QUrl > &urls) |
void | setWidget (QWidget *widget) |
QString | text () const |
QString | title () const |
Urgency | urgency () const |
QList< QUrl > | urls () const |
QWidget * | widget () const |
QString | xdgActivationToken () const |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
Protected Member Functions | |
bool | eventFilter (QObject *watched, QEvent *event) override |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Static Protected Member Functions | |
static QString | standardEventToEventId (StandardEvent event) |
static QString | standardEventToIconName (StandardEvent event) |
Additional Inherited Members | |
![]() | |
typedef | QObjectList |
Detailed Description
KNotification is the main class for creating notifications.
Definition at line 32 of file knotification.h.
Member Typedef Documentation
◆ Context
typedef QPair<QString, QString> KNotification::Context |
Sometimes the user may want different notifications for the same event, depending the source of the event.
Example, you want to be notified for mails that arrive in your folder "personal inbox" but not for those in "spam" folder
A notification context is a pair of two strings. The first string is a key from what the context is. example "group" or "filter" (not translated). The second is the id of the context. In our example, the group id or the filter id in the applications. These strings are the ones present in the config file, and are in theory not shown in the user interface.
The order of contexts in the list is is important, the most important context should be placed first. They are processed in that order when the notification occurs.
- See also
- event
Definition at line 119 of file knotification.h.
◆ NotificationFlags
Stores a combination of NotificationFlag values.
Definition at line 181 of file knotification.h.
Member Enumeration Documentation
◆ NotificationFlag
- See also
- NotificationFlags
Enumerator | |
---|---|
RaiseWidgetOnActivation | When the notification is activated, raise the notification's widget. This will change the desktop, raise the window, and switch to the tab.
|
CloseOnTimeout | The notification will be automatically closed after a timeout. (this is the default) |
Persistent | The notification will NOT be automatically closed after a timeout. You will have to track the notification, and close it with the close function manually when the event is done, otherwise there will be a memory leak |
CloseWhenWidgetActivated | The notification will be automatically closed if the widget() becomes activated. If the widget is already activated when the notification occurs, the notification will be closed after a small timeout. This only works if the widget is the toplevel widget
|
LoopSound | The audio plugin will loop the sound until the notification is closed. |
SkipGrouping | Sends a hint to Plasma to skip grouping for this notification.
|
DefaultEvent | The event is a standard kde event, and not an event of the application |
Definition at line 125 of file knotification.h.
◆ StandardEvent
default events you can use in the event function
Definition at line 187 of file knotification.h.
◆ Urgency
The urgency of a notification.
- Since
- 5.58
- See also
- setUrgency
Definition at line 200 of file knotification.h.
Property Documentation
◆ actions
|
readwrite |
Set the list of actions shown in the popup.
The strings passed in that QStringList will be used as labels for those actions, so ideally they should be wrapped in i18n() or tr() calls. In Plasma workspace, these will be shown as buttons inside the notification popup.
The visual representation of actions however depends on the notification server
- Parameters
-
actions List of strings used as action labels
- Since
- 5.88
Definition at line 64 of file knotification.h.
◆ autoDelete
|
readwrite |
Sets whether this notification object will be automatically deleted after closing.
This is on by default for C++, and off by default for QML.
- Since
- 5.88
- 5.88
Definition at line 89 of file knotification.h.
◆ componentName
|
readwrite |
The componentData is used to determine the location of the config file.
If no componentName is set, the app name is used by default
- Parameters
-
componentName the new component name
- Since
- 5.88
Definition at line 74 of file knotification.h.
◆ defaultAction
|
readwrite |
Set a default action that will be triggered when the notification is activated (typically, by clicking on the notification popup).
The default action should raise a window belonging to the application that sent it.
The string will be used as a label for the action, so ideally it should be wrapped in i18n() or tr() calls.
The visual representation of actions depends on the notification server. In Plasma and Gnome desktops, the actions are performed by clicking on the notification popup, and the label is not presented to the user.
- Parameters
-
action Label of the default action. The label might or might not be displayed to the user by the notification server, depending on the implementation. Passing an empty string disables the default action.
- Since
- 5.31
- 5.88
Definition at line 59 of file knotification.h.
◆ eventId
|
readwrite |
Set the event id, if not already passed to the constructor.
- Since
- 5.88
- 5.88
Definition at line 39 of file knotification.h.
◆ flags
|
readwrite |
Set the notification flags.
These must be set before calling sendEvent()
- Since
- 5.88
Definition at line 69 of file knotification.h.
◆ hints
|
readwrite |
- Since
- 5.57 Adds a custom hint to the notification. Those are key-value pairs that can be interpreted by the respective notification backend to trigger additional, non-standard features.
- Parameters
-
hint the hint's key value the hint's value
- Since
- 5.101
Definition at line 98 of file knotification.h.
◆ iconName
|
readwrite |
Set the icon that will be shown in the popup.
- Parameters
-
icon the icon
- Since
- 5.4
- 5.88
Definition at line 54 of file knotification.h.
◆ text
|
readwrite |
Set the notification text that will appear in the popup.
In Plasma workspace, the text is shown in a QML label which uses Text.StyledText, ie. it supports a small subset of HTML entities (mostly just formatting tags)
If the notifications server does not advertise "body-markup" capability, all HTML tags are stripped before sending it to the server
- Parameters
-
text The text to display in the notification popup
- Since
- 5.88
Definition at line 49 of file knotification.h.
◆ title
|
readwrite |
Set the title of the notification popup.
If no title is set, the application name will be used.
- Parameters
-
title The title of the notification
- Since
- 4.3
- 5.88
Definition at line 44 of file knotification.h.
◆ urgency
|
readwrite |
Sets the urgency of the notification.
This defines the importance of the notification. For example, a track change in a media player would be a low urgency. "You have new mail" would be normal urgency. "Your battery level is low" would be a critical urgency.
Use critical notifications with care as they might be shown even when giving a presentation or when notifications are turned off.
- Parameters
-
urgency The urgency.
- Since
- 5.58
- 5.88
Definition at line 84 of file knotification.h.
◆ urls
Sets URLs associated with this notification.
For example, a screenshot application might want to provide the URL to the file that was just taken so the notification service can show a preview.
- Note
- This feature might not be supported by the user's notification service
- Parameters
-
urls A list of URLs
- Since
- 5.29
- 5.88
Definition at line 79 of file knotification.h.
◆ xdgActivationToken
|
read |
- Since
- 5.90
Definition at line 93 of file knotification.h.
Constructor & Destructor Documentation
◆ KNotification() [1/3]
|
explicit |
Create a new notification.
You have to use sendEvent to show the notification.
The pointer is automatically deleted when the event is closed.
Make sure you use one of the NotificationFlags CloseOnTimeOut or CloseWhenWidgetActivated, if not, you have to close the notification yourself.
- Parameters
-
eventId is the name of the event widget is a widget where the notification reports to flags is a bitmask of NotificationFlag
- Deprecated:
- Since 5.75, use other constructor and call setWidget() explicitly
Definition at line 41 of file knotification.cpp.
◆ KNotification() [2/3]
|
inlineexplicit |
Create a new notification.
You have to use sendEvent to show the notification.
The pointer is automatically deleted when the event is closed.
The NotificationFlags is set to CloseOnTimeout.
- Parameters
-
eventId is the name of the event
- Since
- 5.75
Definition at line 242 of file knotification.h.
◆ KNotification() [3/3]
|
explicit |
Create a new notification.
You have to use sendEvent to show the notification.
The pointer is automatically deleted when the event is closed.
Make sure you use one of the NotificationFlags CloseOnTimeOut or CloseWhenWidgetActivated, if not, you have to close the notification yourself.
- Since
- 4.4
- Parameters
-
eventId is the name of the event flags is a bitmask of NotificationFlag parent parent object
Definition at line 61 of file knotification.cpp.
Member Function Documentation
◆ action1Activated
|
signal |
Convenience signal that is emitted when the first action is activated.
◆ action2Activated
|
signal |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ action3Activated
|
signal |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ actions()
QStringList KNotification::actions | ( | ) | const |
- Returns
- the list of actions
◆ actionsChanged
|
signal |
Emitted when actions
changed.
- Since
- 5.88
◆ activate
|
slot |
Activate the action specified action If the action is zero, then the default action is activated.
Definition at line 324 of file knotification.cpp.
◆ activated [1/2]
|
signal |
Emitted only when the default activation has occurred.
- Deprecated:
- Since 5.67, use defaultActivated() instead
◆ activated [2/2]
|
signal |
Emitted when an action has been activated.
The parameter passed by the signal is the index of the action in the QStringList set by setActions() call.
- Parameters
-
action will be 0 if the default action was activated, or the index of the action in the actions QStringList
◆ addContext() [1/2]
void KNotification::addContext | ( | const Context & | context | ) |
append a context at the list of contexts, see KNotification::Context
- Parameters
-
context the context which is added
Definition at line 252 of file knotification.cpp.
◆ addContext() [2/2]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters
-
context_key is the key of the context context_value is the value of the context
Definition at line 257 of file knotification.cpp.
◆ appName()
QString KNotification::appName | ( | ) | const |
appname used for the D-Bus object
Definition at line 522 of file knotification.cpp.
◆ autoDeleteChanged
|
signal |
Emitted when autoDelete
changed.
- Since
- 5.88
◆ beep()
This is a simple substitution for QApplication::beep()
- Parameters
-
reason a short text explaining what has happened (may be empty) widget the widget the notification refers to
Definition at line 498 of file knotification.cpp.
◆ close
|
slot |
Close the notification without activating it.
This will delete the notification.
Definition at line 350 of file knotification.cpp.
◆ closed
|
signal |
Emitted when the notification is closed.
Can be closed either by the user clicking the close button, the timeout running out or when an action was triggered.
◆ componentName()
QString KNotification::componentName | ( | ) | const |
Returns the component name used to determine the location of the configuration file.
- Since
- 5.88
◆ componentNameChanged
|
signal |
Emitted when componentName
changed.
- Since
- 5.88
◆ contexts()
KNotification::ContextList KNotification::contexts | ( | ) | const |
- Returns
- the list of contexts, see KNotification::Context
Definition at line 242 of file knotification.cpp.
◆ defaultAction()
QString KNotification::defaultAction | ( | ) | const |
- Returns
- the default action, or an empty string if not set
- Since
- 5.31
◆ defaultActionChanged
|
signal |
Emitted when defaultAction
changed.
- Since
- 5.88
◆ defaultActivated
|
signal |
Emitted when the default action has been activated.
- Since
- 5.67
◆ deref
|
slot |
Remove a reference made with ref().
If the ref counter hits zero, the notification will be closed and deleted.
- See also
- ref
Definition at line 488 of file knotification.cpp.
◆ event() [1/7]
|
static |
emit a standard event
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This will emit a standard event
- Parameters
-
eventId is the name of the event text is the text of the notification to show in the popup. pixmap is a picture which may be shown in the popup. widget is a widget where the notification reports to flags is a bitmask of NotificationFlag componentName used to determine the location of the config file. by default, plasma_workspace is used
Definition at line 432 of file knotification.cpp.
◆ event() [2/7]
|
static |
emit an event
This method creates the KNotification, setting every parameter, and fire the event. You don't need to call sendEvent
A popup may be displayed or a sound may be played, depending the config.
- Returns
- a KNotification . You may use that pointer to connect some signals or slot. the pointer is automatically deleted when the event is closed.
Make sure you use one of the CloseOnTimeOut or CloseWhenWidgetActivated, if not, you have to close yourself the notification.
- Parameters
-
eventId is the name of the event title is title of the notification to show in the popup. text is the text of the notification to show in the popup. pixmap is a picture which may be shown in the popup. widget is a widget where the notification reports to flags is a bitmask of NotificationFlag componentName used to determine the location of the config file. by default, appname is used
- Since
- 4.4
Definition at line 412 of file knotification.cpp.
◆ event() [3/7]
|
static |
emit a standard event with the possibility of setting an icon by icon name
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This will emit a standard event
- Parameters
-
eventId is the name of the event title is title of the notification to show in the popup. text is the text of the notification to show in the popup iconName a Freedesktop compatible icon name to be shown in the popup widget is a widget where the notification reports to flags is a bitmask of NotificationFlag componentName used to determine the location of the config file. by default, plasma_workspace is used
- Since
- 5.4
Definition at line 453 of file knotification.cpp.
◆ event() [4/7]
|
static |
emit a standard event
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This will emit a standard event
- Parameters
-
eventId is the name of the event text is the text of the notification to show in the popup pixmap is a picture which may be shown in the popup widget is a widget where the notification reports to flags is a bitmask of NotificationFlag
Definition at line 448 of file knotification.cpp.
◆ event() [5/7]
|
static |
emit a standard event
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This will emit a standard event
- Parameters
-
eventId is the name of the event title is title of the notification to show in the popup. text is the text of the notification to show in the popup pixmap is a picture which may be shown in the popup widget is a widget where the notification reports to flags is a bitmask of NotificationFlag
- Since
- 4.4
Definition at line 443 of file knotification.cpp.
◆ event() [6/7]
|
static |
emit a standard event with the possibility of setting an icon by icon name
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This will emit a standard event with a custom icon
- Parameters
-
eventId the type of the standard (not app-defined) event title is title of the notification to show in the popup. text is the text of the notification to show in the popup iconName a Freedesktop compatible icon name to be shown in the popup widget is a widget where the notification reports to flags is a bitmask of NotificationFlag
- Since
- 5.9
Definition at line 474 of file knotification.cpp.
◆ event() [7/7]
|
static |
emit a standard event
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This will emit a standard event with its standard icon
- Parameters
-
eventId the type of the standard (not app-defined) event title is title of the notification to show in the popup. text is the text of the notification to show in the popup widget is a widget where the notification reports to flags is a bitmask of NotificationFlag
- Since
- 5.9
Definition at line 479 of file knotification.cpp.
◆ eventFilter()
reimplemented for internal reasons
Reimplemented from QObject.
Definition at line 557 of file knotification.cpp.
◆ eventId()
QString KNotification::eventId | ( | ) | const |
- Returns
- the name of the event
◆ eventIdChanged
|
signal |
Emitted when eventId
changed.
- Since
- 5.88
◆ flags()
NotificationFlags KNotification::flags | ( | ) | const |
- Returns
- the notification flags.
◆ flagsChanged
|
signal |
Emitted when flags
changed.
- Since
- 5.88
◆ hints
|
slot |
- Since
- 5.57 Returns the custom hints set by setHint()
◆ hintsChanged
|
signal |
Emitted when hints
changes.
- Since
- 5.101
◆ iconName()
QString KNotification::iconName | ( | ) | const |
◆ iconNameChanged
|
signal |
Emitted when iconName
changed.
- Since
- 5.88
◆ id()
int KNotification::id | ( | ) |
the id given by the notification manager
Definition at line 514 of file knotification.cpp.
◆ ignored
|
signal |
The notification has been ignored.
◆ isAutoDelete()
bool KNotification::isAutoDelete | ( | ) | const |
Returns whether this notification object will be automatically deleted after closing.
- Since
- 5.88
Definition at line 537 of file knotification.cpp.
◆ pixmap()
QPixmap KNotification::pixmap | ( | ) | const |
- Returns
- the pixmap shown in the popup
- See also
- setPixmap
Definition at line 172 of file knotification.cpp.
◆ raiseWidget
|
slot |
Raise the widget.
This will change the desktop, activate the window, and the tab if needed.
- Deprecated:
- since 5.67, use QWindow raise + requestActivate instead.
Definition at line 370 of file knotification.cpp.
◆ ref
|
slot |
The notification will automatically be closed if all presentations are finished.
if you want to show your own presentation in your application, you should use this function, so it will not be automatically closed when there is nothing to show.
Don't forget to deref, or the notification may be never closed if there is no timeout.
- See also
- deref
Definition at line 484 of file knotification.cpp.
◆ replyAction()
KNotificationReplyAction * KNotification::replyAction | ( | ) | const |
◆ sendEvent
|
slot |
Send the notification to the server.
This will cause all the configured plugins to execute their actions on this notification (eg. a sound will play, a popup will show, a command will be executed etc).
Definition at line 503 of file knotification.cpp.
◆ setActions()
void KNotification::setActions | ( | const QStringList & | actions | ) |
Set the list of actions shown in the popup.
The strings passed in that QStringList will be used as labels for those actions, so ideally they should be wrapped in i18n() or tr() calls. In Plasma workspace, these will be shown as buttons inside the notification popup.
The visual representation of actions however depends on the notification server
- Parameters
-
actions List of strings used as action labels
Definition at line 191 of file knotification.cpp.
◆ setAutoDelete()
void KNotification::setAutoDelete | ( | bool | autoDelete | ) |
Sets whether this notification object will be automatically deleted after closing.
This is on by default for C++, and off by default for QML.
- Since
- 5.88
Definition at line 542 of file knotification.cpp.
◆ setComponentName()
void KNotification::setComponentName | ( | const QString & | componentName | ) |
The componentData is used to determine the location of the config file.
If no componentName is set, the app name is used by default
- Parameters
-
componentName the new component name
Definition at line 286 of file knotification.cpp.
◆ setContexts()
void KNotification::setContexts | ( | const ContextList & | contexts | ) |
set the list of contexts, see KNotification::Context
The list of contexts must be set before calling sendEvent;
Definition at line 247 of file knotification.cpp.
◆ setDefaultAction()
void KNotification::setDefaultAction | ( | const QString & | defaultAction | ) |
Set a default action that will be triggered when the notification is activated (typically, by clicking on the notification popup).
The default action should raise a window belonging to the application that sent it.
The string will be used as a label for the action, so ideally it should be wrapped in i18n() or tr() calls.
The visual representation of actions depends on the notification server. In Plasma and Gnome desktops, the actions are performed by clicking on the notification popup, and the label is not presented to the user.
- Parameters
-
action Label of the default action. The label might or might not be displayed to the user by the notification server, depending on the implementation. Passing an empty string disables the default action.
- Since
- 5.31
Definition at line 223 of file knotification.cpp.
◆ setEventId()
void KNotification::setEventId | ( | const QString & | eventId | ) |
Set the event id, if not already passed to the constructor.
- Since
- 5.88
Definition at line 91 of file knotification.cpp.
◆ setFlags()
void KNotification::setFlags | ( | const NotificationFlags & | flags | ) |
Set the notification flags.
These must be set before calling sendEvent()
Definition at line 267 of file knotification.cpp.
◆ setHint
- Since
- 5.57 Adds a custom hint to the notification. Those are key-value pairs that can be interpreted by the respective notification backend to trigger additional, non-standard features.
- Parameters
-
hint the hint's key value the hint's value
Definition at line 614 of file knotification.cpp.
◆ setHints
|
slot |
- Since
- 5.101 Set custom hints on the notification.
- See also
- setHint
Definition at line 633 of file knotification.cpp.
◆ setIconName()
void KNotification::setIconName | ( | const QString & | icon | ) |
Set the icon that will be shown in the popup.
- Parameters
-
icon the icon
- Since
- 5.4
Definition at line 153 of file knotification.cpp.
◆ setPixmap()
void KNotification::setPixmap | ( | const QPixmap & | pix | ) |
Set the pixmap that will be shown in the popup.
If you want to use an icon from the icon theme use setIconName instead.
- Parameters
-
pix the pixmap
Definition at line 177 of file knotification.cpp.
◆ setReplyAction()
void KNotification::setReplyAction | ( | std::unique_ptr< KNotificationReplyAction > | replyAction | ) |
Add an inline reply action to the notification.
On supported platforms this lets the user type a reply to a notification, such as replying to a chat message, from the notification popup, for example:
- Parameters
-
replyAction the reply action to set
- Since
- 5.81
Definition at line 210 of file knotification.cpp.
◆ setText()
void KNotification::setText | ( | const QString & | text | ) |
Set the notification text that will appear in the popup.
In Plasma workspace, the text is shown in a QML label which uses Text.StyledText, ie. it supports a small subset of HTML entities (mostly just formatting tags)
If the notifications server does not advertise "body-markup" capability, all HTML tags are stripped before sending it to the server
- Parameters
-
text The text to display in the notification popup
Definition at line 139 of file knotification.cpp.
◆ setTitle()
void KNotification::setTitle | ( | const QString & | title | ) |
Set the title of the notification popup.
If no title is set, the application name will be used.
- Parameters
-
title The title of the notification
- Since
- 4.3
Definition at line 125 of file knotification.cpp.
◆ setUrgency()
void KNotification::setUrgency | ( | Urgency | urgency | ) |
Sets the urgency of the notification.
This defines the importance of the notification. For example, a track change in a media player would be a low urgency. "You have new mail" would be normal urgency. "Your battery level is low" would be a critical urgency.
Use critical notifications with care as they might be shown even when giving a presentation or when notifications are turned off.
- Parameters
-
urgency The urgency.
- Since
- 5.58
Definition at line 310 of file knotification.cpp.
◆ setUrls()
Sets URLs associated with this notification.
For example, a screenshot application might want to provide the URL to the file that was just taken so the notification service can show a preview.
- Note
- This feature might not be supported by the user's notification service
- Parameters
-
urls A list of URLs
- Since
- 5.29
Definition at line 299 of file knotification.cpp.
◆ setWidget()
void KNotification::setWidget | ( | QWidget * | widget | ) |
Set the widget associated to the notification.
The notification is reparented to the new widget.
- See also
- widget()
- Parameters
-
widget the new widget
Definition at line 114 of file knotification.cpp.
◆ text()
◆ textChanged
|
signal |
Emitted when text
changed.
- Since
- 5.88
◆ title()
◆ titleChanged
|
signal |
Emitted when title
changed.
- Since
- 5.88
◆ update
|
slot |
update the texts, the icon, and the actions of one existing notification
Definition at line 550 of file knotification.cpp.
◆ urgency()
Urgency KNotification::urgency | ( | ) | const |
The urgency of the notification.
- Since
- 5.58
◆ urgencyChanged
|
signal |
Emitted when urgency
changed.
- Since
- 5.88
◆ urls()
◆ urlsChanged
|
signal |
Emitted when urls
changed.
- Since
- 5.88
◆ widget()
QWidget * KNotification::widget | ( | ) | const |
the widget associated to the notification
If the widget is destroyed, the notification will be automatically canceled. If the widget is activated, the notification will be automatically closed if the NotificationFlags specify that
When the notification is activated, the widget might be raised. Depending on the configuration, the taskbar entry of the window containing the widget may blink.
Definition at line 109 of file knotification.cpp.
◆ xdgActivationToken()
QString KNotification::xdgActivationToken | ( | ) | const |
Returns the activation token to use to activate a window.
- Since
- 5.90
◆ xdgActivationTokenChanged
|
signal |
Emitted when xdgActivationToken
changes.
- Since
- 5.90
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:49:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.