libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
stickerevent.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2020 Carl Schwan <carlschwan@kde.org>
2
// SPDX-License-Identifier: LGPL-2.1-or-later
3
4
#
pragma
once
5
6
#
include
"roomevent.h"
7
#
include
"eventcontent.h"
8
9
namespace
Quotient
{
10
11
/// Sticker messages are specialised image messages that are displayed without
12
/// controls (e.g. no "download" link, or light-box view on click, as would be
13
/// displayed for for m.image events).
14
class
QUOTIENT_API
StickerEvent
15
:
public
EventTemplate
<
StickerEvent
,
RoomEvent
,
EventContent
::
ImageContent
>
16
{
17
public
:
18
QUO_EVENT
(
StickerEvent
,
"m.sticker"
)
19
20
StickerEvent
(
const
QString
&
body
,
content_type
imageContent
)
21
:
EventTemplate
(
imageContent
),
m_imageContent
(
std
::
move
(
imageContent
))
22
{
23
replaceSubvalue
(
editJson
(),
ContentKey
,
BodyKey
,
body
);
24
}
25
26
/// \brief A textual representation or associated description of the
27
/// sticker image.
28
///
29
/// This could be the alt text of the original image, or a message to
30
/// accompany and further describe the sticker.
31
QUO_CONTENT_GETTER
(
QString
,
body
)
32
33
/// \brief Metadata about the image referred to in url including a
34
/// thumbnail representation.
35
const
EventContent
::
ImageContent
&
image
()
const
36
{
37
if
(!
m_imageContent
)
38
m_imageContent
.
emplace
(
content
());
39
return
*
m_imageContent
;
40
}
41
42
/// \brief The URL to the sticker image. This must be a valid mxc:// URI.
43
QUrl
url
()
const
44
{
45
return
image
().
url
();
46
}
47
48
protected
:
49
explicit
StickerEvent
(
const
QJsonObject
&
json
) :
EventTemplate
(
json
) {}
50
51
private
:
52
mutable
std
::
optional
<
EventContent
::
ImageContent
>
m_imageContent
;
53
};
54
}
// namespace Quotient
Quotient::StickerEvent
Definition
stickerevent.h:16
QUO_CONTENT_GETTER
#define QUO_CONTENT_GETTER(PartType_, PartName_)
Define an inline method obtaining a content part.
Definition
event.h:452
QUO_EVENT
#define QUO_EVENT(CppType_, MatrixType_)
Supply event metatype information in (specific) event types.
Definition
event.h:428
Quotient
Definition
accountregistry.h:13
QUOTIENT_API
#define QUOTIENT_API
Definition
quotient_export.h:22
Quotient
events
stickerevent.h
Generated by
1.9.8