1 | /* |
2 | This file is part of the KDE Frameworks |
3 | SPDX-FileCopyrightText: 2021 Kai Uwe Broulik <kde@broulik.de> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KNOTIFICATIONREPLYACTION_H |
9 | #define KNOTIFICATIONREPLYACTION_H |
10 | |
11 | #include <knotifications_export.h> |
12 | |
13 | #include <QObject> |
14 | |
15 | #include <memory> |
16 | |
17 | class QString; |
18 | |
19 | class KNotificationReplyActionPrivate; |
20 | |
21 | /*! |
22 | * \class KNotificationReplyAction |
23 | * \inmodule KNotifications |
24 | * |
25 | * \brief An inline reply action. |
26 | * |
27 | * This class represents an inline reply action, which lets the user type a |
28 | * reply to a chat message or email in the notification popup. |
29 | */ |
30 | class KNOTIFICATIONS_EXPORT KNotificationReplyAction : public QObject |
31 | { |
32 | Q_OBJECT |
33 | /*! |
34 | * \property KNotificationReplyAction::label |
35 | * \since 5.88 |
36 | */ |
37 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
38 | /*! |
39 | * \property KNotificationReplyAction::placeholderText |
40 | * \since 5.88 |
41 | */ |
42 | Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged) |
43 | /*! |
44 | * \property KNotificationReplyAction::submitButtonText |
45 | * \since 5.88 |
46 | */ |
47 | Q_PROPERTY(QString submitButtonText READ submitButtonText WRITE setSubmitButtonText NOTIFY submitButtonTextChanged) |
48 | /*! |
49 | * \property KNotificationReplyAction::submitButtonIconName |
50 | * \since 5.88 |
51 | */ |
52 | Q_PROPERTY(QString submitButtonIconName READ submitButtonIconName WRITE setSubmitButtonIconName NOTIFY submitButtonIconNameChanged) |
53 | /*! |
54 | * \property KNotificationReplyAction::fallbackBehavior |
55 | * \since 5.88 |
56 | */ |
57 | Q_PROPERTY(FallbackBehavior fallbackBehavior READ fallbackBehavior WRITE setFallbackBehavior NOTIFY fallbackBehaviorChanged) |
58 | |
59 | public: |
60 | /*! |
61 | * Creates a inline reply action with given label |
62 | * |
63 | * \a label The label for the action |
64 | */ |
65 | explicit KNotificationReplyAction(const QString &label); |
66 | |
67 | ~KNotificationReplyAction() override; |
68 | |
69 | /*! |
70 | * The label for the action button |
71 | */ |
72 | QString label() const; |
73 | /*! |
74 | * Set the label for the action button |
75 | */ |
76 | void setLabel(const QString &label); |
77 | |
78 | /*! |
79 | * The placeholder text for the inline reply text field |
80 | */ |
81 | QString placeholderText() const; |
82 | /*! |
83 | * Set the placeholder text for the inline reply text field, for example "Reply to Konqi..." |
84 | */ |
85 | void setPlaceholderText(const QString &placeholderText); |
86 | |
87 | /*! |
88 | * The label for the button to send the typed reply |
89 | */ |
90 | QString submitButtonText() const; |
91 | /*! |
92 | * Set the label for the button to send the typed reply |
93 | */ |
94 | void setSubmitButtonText(const QString &submitButtonText); |
95 | |
96 | /*! |
97 | * The icon name for the button to send the typed reply |
98 | */ |
99 | QString submitButtonIconName() const; |
100 | /*! |
101 | * Set the icon name for the button to send the typed reply |
102 | */ |
103 | void setSubmitButtonIconName(const QString &submitButtonIconName); |
104 | |
105 | /*! |
106 | * Behavior when the notification server does not support inline replies |
107 | * |
108 | * \value HideAction Don't add the reply action (default) |
109 | * \value UseRegularAction Add the reply action as regular button |
110 | * Use this if you want to provide your own reply functionality |
111 | * Note: The activated() signal is emitted instead of replied() |
112 | */ |
113 | enum class FallbackBehavior { |
114 | HideAction, |
115 | UseRegularAction, |
116 | }; |
117 | Q_ENUM(FallbackBehavior) |
118 | |
119 | /*! |
120 | * Gets the fallback behavior when the notification server does not support inline replies |
121 | */ |
122 | FallbackBehavior fallbackBehavior() const; |
123 | /*! |
124 | * Set the fallback behavior for when the notification server does not support inline replies |
125 | */ |
126 | void setFallbackBehavior(FallbackBehavior fallbackBehavior); |
127 | |
128 | Q_SIGNALS: |
129 | /*! |
130 | * Emitted when the user has submitted a reply |
131 | * |
132 | * \note This is never emitted when the notification server does not support inline replies |
133 | * |
134 | * \a text The text the user entered |
135 | */ |
136 | void replied(const QString &text); |
137 | /*! |
138 | * Emitted when the user clicks the reply fallback button |
139 | * |
140 | * \note This is emitted when the notification server does not support inline replies |
141 | * and fallbackBehavior is set to UseRegularAction. |
142 | */ |
143 | void activated(); |
144 | |
145 | /*! |
146 | * Emitted when label changed. |
147 | * \since 5.88 |
148 | */ |
149 | void labelChanged(); |
150 | /*! |
151 | * Emitted when placeholderText changed. |
152 | * \since 5.88 |
153 | */ |
154 | void placeholderTextChanged(); |
155 | /*! |
156 | * Emitted when submitButtonText changed. |
157 | * \since 5.88 |
158 | */ |
159 | void submitButtonTextChanged(); |
160 | /*! |
161 | * Emitted when submitButtonIconName changed. |
162 | * \since 5.88 |
163 | */ |
164 | void submitButtonIconNameChanged(); |
165 | /*! |
166 | * Emitted when fallbackBehavior changed. |
167 | * \since 5.88 |
168 | */ |
169 | void fallbackBehaviorChanged(); |
170 | |
171 | private: |
172 | std::unique_ptr<KNotificationReplyActionPrivate> const d; |
173 | }; |
174 | |
175 | #endif // KNOTIFICATIONREPLYACTION_H |
176 | |