File indexing completed on 2024-04-14 03:54:12
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2005-2006 Olivier Goffart <ogoffart at kde.org> 0004 SPDX-FileCopyrightText: 2013-2015 Martin Klapetek <mklapetek@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KNOTIFICATION_H 0010 #define KNOTIFICATION_H 0011 0012 #include <knotifications_export.h> 0013 0014 #include <QList> 0015 #include <QObject> 0016 #include <QPair> 0017 #include <QPixmap> 0018 #include <QUrl> 0019 #include <QVariant> 0020 #include <QWindow> 0021 0022 #include <memory> 0023 0024 class KNotificationReplyAction; 0025 class KNotificationAction; 0026 0027 class KNotificationActionPrivate; 0028 0029 /** 0030 * @class KNotificationAction knotification.h KNotificationAction 0031 * 0032 * This class represents a notification. This can be a button on the notification 0033 * popup, or triggered by clicking the notification popup itself. 0034 * 0035 * @since 6.0 0036 */ 0037 class KNOTIFICATIONS_EXPORT KNotificationAction : public QObject 0038 { 0039 Q_OBJECT 0040 /** 0041 * @copydoc label 0042 */ 0043 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) 0044 0045 public: 0046 explicit KNotificationAction(QObject *parent = nullptr); 0047 0048 /** 0049 * Creates an action with given label 0050 * @param label The label for the action 0051 */ 0052 explicit KNotificationAction(const QString &label); 0053 0054 ~KNotificationAction() override; 0055 0056 /** 0057 * The user-facing label for the action 0058 */ 0059 QString label() const; 0060 0061 /** 0062 * Set the user-facing label for the action 0063 */ 0064 void setLabel(const QString &label); 0065 0066 Q_SIGNALS: 0067 /** 0068 * Emitted when the user activates the action 0069 */ 0070 void activated(); 0071 0072 /** 0073 * Emitted when @p label changed. 0074 */ 0075 void labelChanged(const QString &label); 0076 0077 private: 0078 friend class KNotification; 0079 friend class NotifyByPortalPrivate; 0080 friend class NotifyByPopup; 0081 friend class NotifyBySnore; 0082 friend class NotifyByAndroid; 0083 0084 void setId(const QString &id); 0085 QString id() const; 0086 0087 std::unique_ptr<KNotificationActionPrivate> const d; 0088 }; 0089 0090 /** 0091 * @class KNotification knotification.h KNotification 0092 * 0093 * KNotification is the main class for creating notifications. 0094 */ 0095 class KNOTIFICATIONS_EXPORT KNotification : public QObject 0096 { 0097 Q_OBJECT 0098 /** 0099 * @copydoc setEventId 0100 * @since 5.88 0101 */ 0102 Q_PROPERTY(QString eventId READ eventId WRITE setEventId NOTIFY eventIdChanged) 0103 /** 0104 * @copydoc setTitle 0105 * @since 5.88 0106 */ 0107 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) 0108 /** 0109 * @copydoc setText 0110 * @since 5.88 0111 */ 0112 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) 0113 /** 0114 * @copydoc setIconName 0115 * @since 5.88 0116 */ 0117 Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) 0118 /** 0119 * @copydoc setFlags 0120 * @since 5.88 0121 */ 0122 Q_PROPERTY(NotificationFlags flags READ flags WRITE setFlags NOTIFY flagsChanged) 0123 /** 0124 * @copydoc setComponentName 0125 * @since 5.88 0126 */ 0127 Q_PROPERTY(QString componentName READ componentName WRITE setComponentName NOTIFY componentNameChanged) 0128 /** 0129 * @copydoc setUrls 0130 * @since 5.88 0131 */ 0132 Q_PROPERTY(QList<QUrl> urls READ urls WRITE setUrls NOTIFY urlsChanged) 0133 /** 0134 * @copydoc setUrgency 0135 * @since 5.88 0136 */ 0137 Q_PROPERTY(Urgency urgency READ urgency WRITE setUrgency NOTIFY urgencyChanged) 0138 /** 0139 * @copydoc setAutoDelete 0140 * @since 5.88 0141 */ 0142 Q_PROPERTY(bool autoDelete READ isAutoDelete WRITE setAutoDelete NOTIFY autoDeleteChanged) 0143 /** 0144 * @since 5.90 0145 */ 0146 Q_PROPERTY(QString xdgActivationToken READ xdgActivationToken NOTIFY xdgActivationTokenChanged) 0147 /** 0148 * @copydoc setHint 0149 * @since 5.101 0150 */ 0151 Q_PROPERTY(QVariantMap hints READ hints WRITE setHints NOTIFY hintsChanged) 0152 0153 public: 0154 /** 0155 * @see NotificationFlags 0156 */ 0157 enum NotificationFlag { 0158 /** 0159 * The notification will be automatically closed after a timeout. (this is the default) 0160 */ 0161 CloseOnTimeout = 0x00, 0162 0163 /** 0164 * The notification will NOT be automatically closed after a timeout. 0165 * You will have to track the notification, and close it with the 0166 * close function manually when the event is done, otherwise there will be a memory leak 0167 */ 0168 Persistent = 0x02, 0169 0170 /** 0171 * The audio plugin will loop the sound until the notification is closed 0172 */ 0173 LoopSound = 0x08, 0174 0175 /** 0176 * Sends a hint to Plasma to skip grouping for this notification 0177 * 0178 * @since 5.18 0179 */ 0180 SkipGrouping = 0x10, 0181 0182 /** 0183 * The notification will be automatically closed if the window() becomes 0184 * activated. 0185 * 0186 * You need to set a window using setWindow(). 0187 * 0188 * @since 6.0 0189 */ 0190 CloseWhenWindowActivated = 0x20, 0191 0192 /** 0193 * @internal 0194 * The event is a standard kde event, and not an event of the application 0195 */ 0196 DefaultEvent = 0xF000, 0197 0198 }; 0199 0200 /** 0201 * Stores a combination of #NotificationFlag values. 0202 */ 0203 Q_DECLARE_FLAGS(NotificationFlags, NotificationFlag) 0204 Q_FLAG(NotificationFlags) 0205 0206 /** 0207 * default events you can use in the event function 0208 */ 0209 enum StandardEvent { 0210 Notification, 0211 Warning, 0212 Error, 0213 Catastrophe, 0214 }; 0215 0216 /** 0217 * The urgency of a notification. 0218 * 0219 * @since 5.58 0220 * @sa setUrgency 0221 */ 0222 enum Urgency { 0223 DefaultUrgency = -1, 0224 LowUrgency = 10, 0225 NormalUrgency = 50, 0226 HighUrgency = 70, 0227 CriticalUrgency = 90, 0228 }; 0229 Q_ENUM(Urgency) 0230 0231 /** 0232 * Create a new notification. 0233 * 0234 * You have to use sendEvent to show the notification. 0235 * 0236 * The pointer is automatically deleted when the event is closed. 0237 * 0238 * @since 4.4 0239 * 0240 * @param eventId is the name of the event 0241 * @param flags is a bitmask of NotificationFlag 0242 * @param parent parent object 0243 */ 0244 explicit KNotification(const QString &eventId, NotificationFlags flags = CloseOnTimeout, QObject *parent = nullptr); 0245 0246 ~KNotification() override; 0247 0248 /** 0249 * @return the name of the event 0250 */ 0251 QString eventId() const; 0252 /** 0253 * Set the event id, if not already passed to the constructor. 0254 * @since 5.88 0255 */ 0256 void setEventId(const QString &eventId); 0257 0258 /** 0259 * @return the notification title 0260 * @see setTitle 0261 * @since 4.3 0262 */ 0263 QString title() const; 0264 0265 /** 0266 * Set the title of the notification popup. 0267 * If no title is set, the application name will be used. 0268 * 0269 * @param title The title of the notification 0270 * @since 4.3 0271 */ 0272 void setTitle(const QString &title); 0273 0274 /** 0275 * @return the notification text 0276 * @see setText 0277 */ 0278 QString text() const; 0279 0280 /** 0281 * Set the notification text that will appear in the popup. 0282 * 0283 * In Plasma workspace, the text is shown in a QML label which uses Text.StyledText, 0284 * ie. it supports a small subset of HTML entities (mostly just formatting tags) 0285 * 0286 * If the notifications server does not advertise "body-markup" capability, 0287 * all HTML tags are stripped before sending it to the server 0288 * 0289 * @param text The text to display in the notification popup 0290 */ 0291 void setText(const QString &text); 0292 0293 /** 0294 * \return the icon shown in the popup 0295 * \see setIconName 0296 * \since 5.4 0297 */ 0298 QString iconName() const; 0299 0300 /** 0301 * Set the icon that will be shown in the popup. 0302 * 0303 * @param icon the icon 0304 * @since 5.4 0305 */ 0306 void setIconName(const QString &icon); 0307 0308 /** 0309 * \return the pixmap shown in the popup 0310 * \see setPixmap 0311 */ 0312 QPixmap pixmap() const; 0313 /** 0314 * Set the pixmap that will be shown in the popup. If you want to use an icon from the icon theme use setIconName instead. 0315 * 0316 * @param pix the pixmap 0317 */ 0318 void setPixmap(const QPixmap &pix); 0319 0320 /** 0321 * @return the default action, or nullptr if none is set 0322 * @since 6.0 0323 */ 0324 KNotificationAction *defaultAction() const; 0325 0326 /** 0327 * Add a default action that will be triggered when the notification is 0328 * activated (typically, by clicking on the notification popup). The default 0329 * action typically raises a window belonging to the application that sent it. 0330 * 0331 * The string will be used as a label for the action, so ideally it should 0332 * be wrapped in i18n() or tr() calls. 0333 * 0334 * The visual representation of actions depends on the notification server. 0335 * In Plasma and Gnome desktops, the actions are performed by clicking on 0336 * the notification popup, and the label is not presented to the user. 0337 * 0338 * Calling this overrides the current default action 0339 * 0340 * @since 6.0 0341 */ 0342 [[nodiscard]] KNotificationAction *addDefaultAction(const QString &label); 0343 0344 /** 0345 * Add an action to the notification. 0346 * 0347 * The visual representation of actions depends 0348 * on the notification server. 0349 * 0350 * @param label the user-visible label of the action 0351 * 0352 * @see KNotificationAction 0353 * 0354 * @since 6.0 0355 */ 0356 [[nodiscard]] KNotificationAction *addAction(const QString &label); 0357 0358 /** 0359 * Removes all actions previously added by addAction() 0360 * from the notification. 0361 * 0362 * @see addAction 0363 * 0364 * @since 6.0 0365 */ 0366 void clearActions(); 0367 0368 /** 0369 * @return the inline reply action. 0370 * @since 5.81 0371 */ 0372 KNotificationReplyAction *replyAction() const; 0373 0374 /** 0375 * @brief Add an inline reply action to the notification. 0376 * 0377 * On supported platforms this lets the user type a reply to a notification, 0378 * such as replying to a chat message, from the notification popup, for example: 0379 * 0380 * @code{.cpp} 0381 * KNotification *notification = new KNotification(QStringLiteral("notification")); 0382 * ... 0383 * auto replyAction = std::make_unique<KNotificationReplyAction>(i18nc("@action:button", "Reply")); 0384 * replyAction->setPlaceholderText(i18nc("@info:placeholder", "Reply to Dave...")); 0385 * QObject::connect(replyAction.get(), &KNotificationReplyAction::replied, [](const QString &text) { 0386 * qDebug() << "you replied with" << text; 0387 * }); 0388 * notification->setReplyAction(std::move(replyAction)); 0389 * @endcode 0390 * 0391 * @param replyAction the reply action to set 0392 * @since 5.81 0393 */ 0394 void setReplyAction(std::unique_ptr<KNotificationReplyAction> replyAction); 0395 0396 /** 0397 * @return the notification flags. 0398 */ 0399 NotificationFlags flags() const; 0400 0401 /** 0402 * Set the notification flags. 0403 * These must be set before calling sendEvent() 0404 */ 0405 void setFlags(const NotificationFlags &flags); 0406 0407 /** 0408 * Returns the component name used to determine the location of the configuration file. 0409 * @since 5.88 0410 */ 0411 QString componentName() const; 0412 /** 0413 * The componentData is used to determine the location of the config file. 0414 * 0415 * If no componentName is set, the app name is used by default 0416 * 0417 * @param componentName the new component name 0418 */ 0419 void setComponentName(const QString &componentName); 0420 0421 /** 0422 * URLs associated with this notification 0423 * @since 5.29 0424 */ 0425 QList<QUrl> urls() const; 0426 0427 /** 0428 * Sets URLs associated with this notification 0429 * 0430 * For example, a screenshot application might want to provide the 0431 * URL to the file that was just taken so the notification service 0432 * can show a preview. 0433 * 0434 * @note This feature might not be supported by the user's notification service 0435 * 0436 * @param urls A list of URLs 0437 * @since 5.29 0438 */ 0439 void setUrls(const QList<QUrl> &urls); 0440 0441 /** 0442 * The urgency of the notification. 0443 * @since 5.58 0444 */ 0445 Urgency urgency() const; 0446 0447 /** 0448 * Sets the urgency of the notification. 0449 * 0450 * This defines the importance of the notification. For example, 0451 * a track change in a media player would be a low urgency. 0452 * "You have new mail" would be normal urgency. "Your battery level 0453 * is low" would be a critical urgency. 0454 * 0455 * Use critical notifications with care as they might be shown even 0456 * when giving a presentation or when notifications are turned off. 0457 * 0458 * @param urgency The urgency. 0459 * @since 5.58 0460 */ 0461 void setUrgency(Urgency urgency); 0462 0463 /** 0464 * Sets the window associated with this notification. 0465 * This is relevant when using the CloseWhenWindowActivated flag. 0466 * 0467 * @since 6.0 0468 */ 0469 void setWindow(QWindow *window); 0470 0471 /** 0472 * The window associated with this notification. nullptr by default. 0473 * @return the window set by setWindow() 0474 * 0475 * @since 6.0 0476 */ 0477 QWindow *window() const; 0478 0479 /** 0480 * @internal 0481 * appname used for the D-Bus object 0482 */ 0483 QString appName() const; 0484 0485 /** 0486 * Returns whether this notification object will be automatically deleted after closing. 0487 * @since 5.88 0488 */ 0489 bool isAutoDelete() const; 0490 /** 0491 * Sets whether this notification object will be automatically deleted after closing. 0492 * This is on by default for C++, and off by default for QML. 0493 * @since 5.88 0494 */ 0495 void setAutoDelete(bool autoDelete); 0496 0497 /** 0498 * Returns the activation token to use to activate a window. 0499 * @since 5.90 0500 */ 0501 QString xdgActivationToken() const; 0502 0503 Q_SIGNALS: 0504 /** 0505 * Emitted when the notification is closed. 0506 * 0507 * Can be closed either by the user clicking the close button, 0508 * the timeout running out or when an action was triggered. 0509 */ 0510 void closed(); 0511 0512 /** 0513 * The notification has been ignored 0514 */ 0515 void ignored(); 0516 0517 /** 0518 * Emitted when @c eventId changed. 0519 * @since 5.88 0520 */ 0521 void eventIdChanged(); 0522 /** 0523 * Emitted when @c title changed. 0524 * @since 5.88 0525 */ 0526 void titleChanged(); 0527 /** 0528 * Emitted when @c text changed. 0529 * @since 5.88 0530 */ 0531 void textChanged(); 0532 /** 0533 * Emitted when @c iconName changed. 0534 * @since 5.88 0535 */ 0536 void iconNameChanged(); 0537 /** 0538 * Emitted when @c defaultAction changed. 0539 * @since 5.88 0540 */ 0541 void defaultActionChanged(); 0542 /** 0543 * Emitted when @c actions changed. 0544 * @since 5.88 0545 */ 0546 void actionsChanged(); 0547 /** 0548 * Emitted when @p flags changed. 0549 * @since 5.88 0550 */ 0551 void flagsChanged(); 0552 /** 0553 * Emitted when @p componentName changed. 0554 * @since 5.88 0555 */ 0556 void componentNameChanged(); 0557 /** 0558 * Emitted when @p urls changed. 0559 * @since 5.88 0560 */ 0561 void urlsChanged(); 0562 /** 0563 * Emitted when @p urgency changed. 0564 * @since 5.88 0565 */ 0566 void urgencyChanged(); 0567 /** 0568 * Emitted when @p autoDelete changed. 0569 * @since 5.88 0570 */ 0571 void autoDeleteChanged(); 0572 /** 0573 * Emitted when @p xdgActivationToken changes. 0574 * @since 5.90 0575 */ 0576 void xdgActivationTokenChanged(); 0577 /** 0578 * Emitted when @p hints changes. 0579 * @since 5.101 0580 */ 0581 void hintsChanged(); 0582 0583 public Q_SLOTS: 0584 /** 0585 * Close the notification without activating it. 0586 * 0587 * This will delete the notification. 0588 */ 0589 void close(); 0590 0591 /** 0592 * Send the notification to the server. 0593 * 0594 * This will cause all the configured plugins to execute their actions on this notification 0595 * (eg. a sound will play, a popup will show, a command will be executed etc). 0596 */ 0597 void sendEvent(); 0598 0599 /** 0600 * @since 5.57 0601 * Adds a custom hint to the notification. Those are key-value pairs that can be interpreted by the respective notification backend to trigger additional, 0602 * non-standard features. 0603 * @param hint the hint's key 0604 * @param value the hint's value 0605 */ 0606 Q_INVOKABLE void setHint(const QString &hint, const QVariant &value); 0607 0608 /** 0609 * @since 5.57 0610 * Returns the custom hints set by setHint() 0611 */ 0612 QVariantMap hints() const; 0613 0614 /** 0615 * @since 5.101 0616 * Set custom hints on the notification. 0617 * @sa setHint 0618 */ 0619 void setHints(const QVariantMap &hints); 0620 0621 private: 0622 friend class KNotificationManager; 0623 friend class NotificationWrapper; 0624 friend class NotifyByPopup; 0625 friend class NotifyByPortal; 0626 friend class NotifyByPortalPrivate; 0627 friend class NotifyByExecute; 0628 friend class NotifyBySnore; 0629 friend class NotifyByAndroid; 0630 friend class NotifyByMacOSNotificationCenter; 0631 struct Private; 0632 0633 KNOTIFICATIONS_NO_EXPORT void slotWindowActiveChanged(); 0634 0635 /** 0636 * @brief Activate the action specified action 0637 * If the action is zero, then the default action is activated 0638 */ 0639 KNOTIFICATIONS_NO_EXPORT void activate(const QString &action); 0640 0641 /** 0642 * @internal 0643 * the id given by the notification manager 0644 */ 0645 KNOTIFICATIONS_NO_EXPORT int id(); 0646 0647 /** 0648 * @internal 0649 * update the texts, the icon, and the actions of one existing notification 0650 */ 0651 KNOTIFICATIONS_NO_EXPORT void update(); 0652 0653 /** 0654 * The notification will automatically be closed if all presentations are finished. 0655 * if you want to show your own presentation in your application, you should use this 0656 * function, so it will not be automatically closed when there is nothing to show. 0657 * 0658 * Don't forgot to deref, or the notification may be never closed if there is no timeout. 0659 * 0660 * @see deref 0661 */ 0662 KNOTIFICATIONS_NO_EXPORT void ref(); 0663 0664 /** 0665 * Remove a reference made with ref(). If the ref counter hits zero, 0666 * the notification will be closed and deleted. 0667 * 0668 * @see ref 0669 */ 0670 KNOTIFICATIONS_NO_EXPORT void deref(); 0671 0672 // Like setActions, but doesn't take ownership 0673 void setActionsQml(QList<KNotificationAction *> actions); 0674 void setDefaultActionQml(KNotificationAction *action); 0675 QList<KNotificationAction *> actions() const; 0676 0677 static QString standardEventToEventId(StandardEvent event); 0678 static QString standardEventToIconName(StandardEvent event); 0679 0680 std::unique_ptr<Private> const d; 0681 0682 public: 0683 /** 0684 * @brief emit an event 0685 * 0686 * This method creates the KNotification, setting every parameter, and fire the event. 0687 * You don't need to call sendEvent 0688 * 0689 * A popup may be displayed or a sound may be played, depending the config. 0690 * 0691 * @return a KNotification . You may use that pointer to connect some signals or slot. 0692 * the pointer is automatically deleted when the event is closed. 0693 * 0694 * @param eventId is the name of the event 0695 * @param title is title of the notification to show in the popup. 0696 * @param text is the text of the notification to show in the popup. 0697 * @param pixmap is a picture which may be shown in the popup. 0698 * @param flags is a bitmask of NotificationFlag 0699 * @param componentName used to determine the location of the config file. by default, appname is used 0700 * @since 4.4 0701 */ 0702 static KNotification *event(const QString &eventId, 0703 const QString &title, 0704 const QString &text, 0705 const QPixmap &pixmap = QPixmap(), 0706 const NotificationFlags &flags = CloseOnTimeout, 0707 const QString &componentName = QString()); 0708 0709 /** 0710 * @brief emit a standard event 0711 * 0712 * @overload 0713 * 0714 * This will emit a standard event 0715 * 0716 * @param eventId is the name of the event 0717 * @param text is the text of the notification to show in the popup. 0718 * @param pixmap is a picture which may be shown in the popup. 0719 * @param flags is a bitmask of NotificationFlag 0720 * @param componentName used to determine the location of the config file. by default, plasma_workspace is used 0721 */ 0722 static KNotification *event(const QString &eventId, 0723 const QString &text = QString(), 0724 const QPixmap &pixmap = QPixmap(), 0725 const NotificationFlags &flags = CloseOnTimeout, 0726 const QString &componentName = QString()); 0727 0728 /** 0729 * @brief emit a standard event 0730 * 0731 * @overload 0732 * 0733 * This will emit a standard event 0734 * 0735 * @param eventId is the name of the event 0736 * @param text is the text of the notification to show in the popup 0737 * @param pixmap is a picture which may be shown in the popup 0738 * @param flags is a bitmask of NotificationFlag 0739 */ 0740 static KNotification * 0741 event(StandardEvent eventId, const QString &text = QString(), const QPixmap &pixmap = QPixmap(), const NotificationFlags &flags = CloseOnTimeout); 0742 0743 /** 0744 * @brief emit a standard event 0745 * 0746 * @overload 0747 * 0748 * This will emit a standard event 0749 * 0750 * @param eventId is the name of the event 0751 * @param title is title of the notification to show in the popup. 0752 * @param text is the text of the notification to show in the popup 0753 * @param pixmap is a picture which may be shown in the popup 0754 * @param flags is a bitmask of NotificationFlag 0755 * @since 4.4 0756 */ 0757 static KNotification * 0758 event(StandardEvent eventId, const QString &title, const QString &text, const QPixmap &pixmap, const NotificationFlags &flags = CloseOnTimeout); 0759 0760 /** 0761 * @brief emit a standard event with the possibility of setting an icon by icon name 0762 * 0763 * @overload 0764 * 0765 * This will emit a standard event 0766 * 0767 * @param eventId is the name of the event 0768 * @param title is title of the notification to show in the popup. 0769 * @param text is the text of the notification to show in the popup 0770 * @param iconName a Freedesktop compatible icon name to be shown in the popup 0771 * @param flags is a bitmask of NotificationFlag 0772 * @param componentName used to determine the location of the config file. by default, plasma_workspace is used 0773 * @since 5.4 0774 */ 0775 static KNotification *event(const QString &eventId, 0776 const QString &title, 0777 const QString &text, 0778 const QString &iconName, 0779 const NotificationFlags &flags = CloseOnTimeout, 0780 const QString &componentName = QString()); 0781 0782 /** 0783 * @brief emit a standard event with the possibility of setting an icon by icon name 0784 * 0785 * @overload 0786 * 0787 * This will emit a standard event with a custom icon 0788 * 0789 * @param eventId the type of the standard (not app-defined) event 0790 * @param title is title of the notification to show in the popup. 0791 * @param text is the text of the notification to show in the popup 0792 * @param iconName a Freedesktop compatible icon name to be shown in the popup 0793 * @param flags is a bitmask of NotificationFlag 0794 * @since 5.9 0795 */ 0796 static KNotification * 0797 event(StandardEvent eventId, const QString &title, const QString &text, const QString &iconName, const NotificationFlags &flags = CloseOnTimeout); 0798 0799 /** 0800 * @brief emit a standard event 0801 * 0802 * @overload 0803 * 0804 * This will emit a standard event with its standard icon 0805 * 0806 * @param eventId the type of the standard (not app-defined) event 0807 * @param title is title of the notification to show in the popup. 0808 * @param text is the text of the notification to show in the popup 0809 * @param flags is a bitmask of NotificationFlag 0810 * @since 5.9 0811 */ 0812 static KNotification *event(StandardEvent eventId, const QString &title, const QString &text, const NotificationFlags &flags = CloseOnTimeout); 0813 0814 /** 0815 * This is a simple substitution for QApplication::beep() 0816 * 0817 * @param reason a short text explaining what has happened (may be empty) 0818 */ 0819 static void beep(const QString &reason = QString()); 0820 0821 // prevent warning 0822 using QObject::event; 0823 }; 0824 0825 Q_DECLARE_OPERATORS_FOR_FLAGS(KNotification::NotificationFlags) 0826 0827 #endif