File indexing completed on 2024-04-28 15:29:09
0001 /* 0002 This file is part of the KDE Frameworks 0003 SPDX-FileCopyrightText: 2021 Kai Uwe Broulik <kde@broulik.de> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KNOTIFICATIONREPLYACTION_H 0009 #define KNOTIFICATIONREPLYACTION_H 0010 0011 #include <knotifications_export.h> 0012 0013 #include <QObject> 0014 0015 #include <memory> 0016 0017 class QString; 0018 0019 class KNotificationReplyActionPrivate; 0020 0021 /** 0022 * @class KNotificationReplyAction knotificationreplyaction.h KNotificationReplyAction 0023 * 0024 * @brief An inline reply action 0025 * 0026 * This class represents an inline reply action, which lets the user type a 0027 * reply to a chat message or email in the notification popup. 0028 */ 0029 class KNOTIFICATIONS_EXPORT KNotificationReplyAction : public QObject 0030 { 0031 Q_OBJECT 0032 /** 0033 * @copydoc label 0034 * @since 5.88 0035 */ 0036 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) 0037 /** 0038 * @copydoc placeholderText 0039 * @since 5.88 0040 */ 0041 Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged) 0042 /** 0043 * @copydoc submitButtonText 0044 * @since 5.88 0045 */ 0046 Q_PROPERTY(QString submitButtonText READ submitButtonText WRITE setSubmitButtonText NOTIFY submitButtonTextChanged) 0047 /** 0048 * @copydoc submitButtonIconName 0049 * @since 5.88 0050 */ 0051 Q_PROPERTY(QString submitButtonIconName READ submitButtonIconName WRITE setSubmitButtonIconName NOTIFY submitButtonIconNameChanged) 0052 /** 0053 * @copydoc fallbackBehavior 0054 * @since 5.88 0055 */ 0056 Q_PROPERTY(FallbackBehavior fallbackBehavior READ fallbackBehavior WRITE setFallbackBehavior NOTIFY fallbackBehaviorChanged) 0057 0058 public: 0059 /** 0060 * Creates a inline reply action with given label 0061 * @param label The label for the action 0062 */ 0063 explicit KNotificationReplyAction(const QString &label); 0064 /** 0065 * Destroys this inline reply action 0066 */ 0067 ~KNotificationReplyAction() override; 0068 0069 /** 0070 * The label for the action button 0071 */ 0072 QString label() const; 0073 /** 0074 * Set the label for the action button 0075 */ 0076 void setLabel(const QString &label); 0077 0078 /** 0079 * The placeholder text for the inline reply text field 0080 */ 0081 QString placeholderText() const; 0082 /** 0083 * Set the placeholder text for the inline reply text field, for example "Reply to Konqi..." 0084 */ 0085 void setPlaceholderText(const QString &placeholderText); 0086 0087 /** 0088 * The label for the button to send the typed reply 0089 */ 0090 QString submitButtonText() const; 0091 /** 0092 * Set the label for the button to send the typed reply 0093 */ 0094 void setSubmitButtonText(const QString &submitButtonText); 0095 0096 /** 0097 * The icon name for the button to send the typed reply 0098 */ 0099 QString submitButtonIconName() const; 0100 /** 0101 * Set the icon name for the button to send the typed reply 0102 */ 0103 void setSubmitButtonIconName(const QString &submitButtonIconName); 0104 0105 /** 0106 * Behavior when the notification server does not support inline replies 0107 */ 0108 enum class FallbackBehavior { 0109 /** 0110 * Don't add the reply action (default) 0111 */ 0112 HideAction, 0113 /** 0114 * Add the reply action as regular button 0115 * 0116 * Use this if you want to provide your own reply functionality 0117 * 0118 * @note The @c activated signal is emitted instead of @c replied! 0119 */ 0120 UseRegularAction, 0121 }; 0122 Q_ENUM(FallbackBehavior) 0123 0124 /** 0125 * Gets the fallback behavior when the notification server does not support inline replies 0126 */ 0127 FallbackBehavior fallbackBehavior() const; 0128 /** 0129 * Set the fallback behavior for when the notification server does not support inline replies 0130 */ 0131 void setFallbackBehavior(FallbackBehavior fallbackBehavior); 0132 0133 Q_SIGNALS: 0134 /** 0135 * Emitted when the user has submitted a reply 0136 * 0137 * @note This is never emitted when the notification server does not support inline replies 0138 * 0139 * @param text The text the user entered 0140 */ 0141 void replied(const QString &text); 0142 /** 0143 * Emitted when the user clicks the reply fallback button 0144 * 0145 * @note This is emitted when the notification server does not support inline replies 0146 * and fallbackBehavior is set to @c UseRegularAction. 0147 */ 0148 void activated(); 0149 0150 /** 0151 * Emitted when @p label changed. 0152 * @since 5.88 0153 */ 0154 void labelChanged(); 0155 /** 0156 * Emitted when @p placeholderText changed. 0157 * @since 5.88 0158 */ 0159 void placeholderTextChanged(); 0160 /** 0161 * Emitted when @p submitButtonText changed. 0162 * @since 5.88 0163 */ 0164 void submitButtonTextChanged(); 0165 /** 0166 * Emitted when @p submitButtonIconName changed. 0167 * @since 5.88 0168 */ 0169 void submitButtonIconNameChanged(); 0170 /** 0171 * Emitted when @p fallbackBehavior changed. 0172 * @since 5.88 0173 */ 0174 void fallbackBehaviorChanged(); 0175 0176 private: 0177 std::unique_ptr<KNotificationReplyActionPrivate> const d; 0178 }; 0179 0180 #endif // KNOTIFICATIONREPLYACTION_H