KNotifications

knotificationreplyaction.h
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
17class QString;
18
19class KNotificationReplyActionPrivate;
20
21/**
22 * @class KNotificationReplyAction knotificationreplyaction.h KNotificationReplyAction
23 *
24 * @brief An inline reply action
25 *
26 * This class represents an inline reply action, which lets the user type a
27 * reply to a chat message or email in the notification popup.
28 */
29class KNOTIFICATIONS_EXPORT KNotificationReplyAction : public QObject
30{
31 Q_OBJECT
32 /**
33 * @copydoc label
34 * @since 5.88
35 */
36 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
37 /**
38 * @copydoc placeholderText
39 * @since 5.88
40 */
41 Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged)
42 /**
43 * @copydoc submitButtonText
44 * @since 5.88
45 */
46 Q_PROPERTY(QString submitButtonText READ submitButtonText WRITE setSubmitButtonText NOTIFY submitButtonTextChanged)
47 /**
48 * @copydoc submitButtonIconName
49 * @since 5.88
50 */
51 Q_PROPERTY(QString submitButtonIconName READ submitButtonIconName WRITE setSubmitButtonIconName NOTIFY submitButtonIconNameChanged)
52 /**
53 * @copydoc fallbackBehavior
54 * @since 5.88
55 */
56 Q_PROPERTY(FallbackBehavior fallbackBehavior READ fallbackBehavior WRITE setFallbackBehavior NOTIFY fallbackBehaviorChanged)
57
58public:
59 /**
60 * Creates a inline reply action with given label
61 * @param label The label for the action
62 */
63 explicit KNotificationReplyAction(const QString &label);
64 /**
65 * Destroys this inline reply action
66 */
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 enum class FallbackBehavior {
109 /**
110 * Don't add the reply action (default)
111 */
112 HideAction,
113 /**
114 * Add the reply action as regular button
115 *
116 * Use this if you want to provide your own reply functionality
117 *
118 * @note The @c activated signal is emitted instead of @c replied!
119 */
120 UseRegularAction,
121 };
122 Q_ENUM(FallbackBehavior)
123
124 /**
125 * Gets the fallback behavior when the notification server does not support inline replies
126 */
127 FallbackBehavior fallbackBehavior() const;
128 /**
129 * Set the fallback behavior for when the notification server does not support inline replies
130 */
131 void setFallbackBehavior(FallbackBehavior fallbackBehavior);
132
134 /**
135 * Emitted when the user has submitted a reply
136 *
137 * @note This is never emitted when the notification server does not support inline replies
138 *
139 * @param text The text the user entered
140 */
141 void replied(const QString &text);
142 /**
143 * Emitted when the user clicks the reply fallback button
144 *
145 * @note This is emitted when the notification server does not support inline replies
146 * and fallbackBehavior is set to @c UseRegularAction.
147 */
148 void activated();
149
150 /**
151 * Emitted when @p label changed.
152 * @since 5.88
153 */
155 /**
156 * Emitted when @p placeholderText changed.
157 * @since 5.88
158 */
160 /**
161 * Emitted when @p submitButtonText changed.
162 * @since 5.88
163 */
165 /**
166 * Emitted when @p submitButtonIconName changed.
167 * @since 5.88
168 */
170 /**
171 * Emitted when @p fallbackBehavior changed.
172 * @since 5.88
173 */
175
176private:
177 std::unique_ptr<KNotificationReplyActionPrivate> const d;
178};
179
180#endif // KNOTIFICATIONREPLYACTION_H
void labelChanged()
Emitted when label changed.
void fallbackBehaviorChanged()
Emitted when fallbackBehavior changed.
void placeholderTextChanged()
Emitted when placeholderText changed.
FallbackBehavior
Behavior when the notification server does not support inline replies.
void submitButtonIconNameChanged()
Emitted when submitButtonIconName changed.
void activated()
Emitted when the user clicks the reply fallback button.
void submitButtonTextChanged()
Emitted when submitButtonText changed.
void replied(const QString &text)
Emitted when the user has submitted a reply.
Q_ENUM(...)
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:12:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.