Show custom delegate for in-room user verification

This is independent of the in-room verification actually working, but prevents a fallback from appearing
This commit is contained in:
Tobias Fella
2024-03-23 20:56:30 +01:00
parent c3fd2428a2
commit ab4519dedd
3 changed files with 66 additions and 52 deletions

View File

@@ -51,6 +51,7 @@ public:
LinkPreview, /**< A preview of a URL in the message. */ LinkPreview, /**< A preview of a URL in the message. */
LinkPreviewLoad, /**< A loading dialog for a link preview. */ LinkPreviewLoad, /**< A loading dialog for a link preview. */
Edit, /**< A text edit for editing a message. */ Edit, /**< A text edit for editing a message. */
Verification, /**< A user verification session start message. */
Other, /**< Anything that cannot be classified as another type. */ Other, /**< Anything that cannot be classified as another type. */
}; };
Q_ENUM(Type); Q_ENUM(Type);

View File

@@ -244,6 +244,10 @@ void MessageContentModel::updateComponents(bool isEditing)
beginResetModel(); beginResetModel();
m_components.clear(); m_components.clear();
if (eventCast<const Quotient::RoomMessageEvent>(m_event)
&& eventCast<const Quotient::RoomMessageEvent>(m_event)->rawMsgtype() == QStringLiteral("m.key.verification.request")) {
m_components += MessageComponent{MessageComponentType::Verification, QString(), {}};
} else {
EventHandler eventHandler(m_room, m_event); EventHandler eventHandler(m_room, m_event);
if (eventHandler.hasReply()) { if (eventHandler.hasReply()) {
if (m_room->findInTimeline(eventHandler.getReplyId()) == m_room->historyEdge()) { if (m_room->findInTimeline(eventHandler.getReplyId()) == m_room->historyEdge()) {
@@ -310,6 +314,7 @@ void MessageContentModel::updateComponents(bool isEditing)
m_components += MessageComponent{MessageComponentType::LinkPreviewLoad, QString(), {}}; m_components += MessageComponent{MessageComponentType::LinkPreviewLoad, QString(), {}};
} }
} }
}
endResetModel(); endResetModel();
} }

View File

@@ -213,6 +213,14 @@ DelegateChooser {
} }
} }
DelegateChoice {
roleValue: MessageComponentType.Verification
delegate: MimeComponent {
mimeIconSource: "security-high"
label: i18n("%1 started a user verification", model.author.escapedDisplayName)
}
}
DelegateChoice { DelegateChoice {
roleValue: MessageComponentType.Other roleValue: MessageComponentType.Other
delegate: Item {} delegate: Item {}