mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
Use the new mtxclient special effects refactoring
This commit is contained in:
parent
e026242a62
commit
138b0a6b86
8 changed files with 69 additions and 55 deletions
|
@ -602,7 +602,7 @@ if(USE_BUNDLED_MTXCLIENT)
|
|||
FetchContent_Declare(
|
||||
MatrixClient
|
||||
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
||||
GIT_TAG c8849cd033bb59bee39f3fb2eaca953853731eb2
|
||||
GIT_TAG f8a9cbbb25ea145a23506c2f9386f6c61401bed0
|
||||
)
|
||||
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
||||
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
||||
|
|
|
@ -213,7 +213,7 @@ modules:
|
|||
buildsystem: cmake-ninja
|
||||
name: mtxclient
|
||||
sources:
|
||||
- commit: c8849cd033bb59bee39f3fb2eaca953853731eb2
|
||||
- commit: f8a9cbbb25ea145a23506c2f9386f6c61401bed0
|
||||
#tag: v0.9.2
|
||||
type: git
|
||||
url: https://github.com/Nheko-Reborn/mtxclient.git
|
||||
|
|
|
@ -116,7 +116,7 @@ Item {
|
|||
}
|
||||
|
||||
DelegateChoice {
|
||||
roleValue: MtxEvent.ConfettiMessage
|
||||
roleValue: MtxEvent.ElementEffectMessage
|
||||
|
||||
TextMessage {
|
||||
formatted: d.formattedBody
|
||||
|
|
|
@ -215,20 +215,20 @@ utils::getMessageDescription(const TimelineEvent &event,
|
|||
const QString &localUser,
|
||||
const QString &displayName)
|
||||
{
|
||||
using Audio = mtx::events::RoomEvent<mtx::events::msg::Audio>;
|
||||
using Emote = mtx::events::RoomEvent<mtx::events::msg::Emote>;
|
||||
using File = mtx::events::RoomEvent<mtx::events::msg::File>;
|
||||
using Image = mtx::events::RoomEvent<mtx::events::msg::Image>;
|
||||
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||
using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>;
|
||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||
using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>;
|
||||
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
||||
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
||||
using CallReject = mtx::events::RoomEvent<mtx::events::voip::CallReject>;
|
||||
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
||||
using Audio = mtx::events::RoomEvent<mtx::events::msg::Audio>;
|
||||
using Emote = mtx::events::RoomEvent<mtx::events::msg::Emote>;
|
||||
using File = mtx::events::RoomEvent<mtx::events::msg::File>;
|
||||
using Image = mtx::events::RoomEvent<mtx::events::msg::Image>;
|
||||
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||
using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>;
|
||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||
using ElementEffect = mtx::events::RoomEvent<mtx::events::msg::ElementEffect>;
|
||||
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
||||
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
||||
using CallReject = mtx::events::RoomEvent<mtx::events::voip::CallReject>;
|
||||
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
||||
|
||||
if (std::holds_alternative<Audio>(event)) {
|
||||
return createDescriptionInfo<Audio>(event, localUser, displayName);
|
||||
|
@ -246,8 +246,8 @@ utils::getMessageDescription(const TimelineEvent &event,
|
|||
return createDescriptionInfo<Unknown>(event, localUser, displayName);
|
||||
} else if (std::holds_alternative<Video>(event)) {
|
||||
return createDescriptionInfo<Video>(event, localUser, displayName);
|
||||
} else if (std::holds_alternative<Confetti>(event)) {
|
||||
return createDescriptionInfo<Confetti>(event, localUser, displayName);
|
||||
} else if (std::holds_alternative<ElementEffect>(event)) {
|
||||
return createDescriptionInfo<ElementEffect>(event, localUser, displayName);
|
||||
} else if (std::holds_alternative<CallInvite>(event)) {
|
||||
return createDescriptionInfo<CallInvite>(event, localUser, displayName);
|
||||
} else if (std::holds_alternative<CallAnswer>(event)) {
|
||||
|
|
37
src/Utils.h
37
src/Utils.h
|
@ -95,21 +95,21 @@ messageDescription(const QString &username = QString(),
|
|||
const QString &body = QString(),
|
||||
const bool isLocal = false)
|
||||
{
|
||||
using Audio = mtx::events::RoomEvent<mtx::events::msg::Audio>;
|
||||
using Emote = mtx::events::RoomEvent<mtx::events::msg::Emote>;
|
||||
using File = mtx::events::RoomEvent<mtx::events::msg::File>;
|
||||
using Image = mtx::events::RoomEvent<mtx::events::msg::Image>;
|
||||
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
||||
using Sticker = mtx::events::Sticker;
|
||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||
using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>;
|
||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||
using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>;
|
||||
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
||||
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
||||
using CallReject = mtx::events::RoomEvent<mtx::events::voip::CallReject>;
|
||||
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
||||
using Audio = mtx::events::RoomEvent<mtx::events::msg::Audio>;
|
||||
using Emote = mtx::events::RoomEvent<mtx::events::msg::Emote>;
|
||||
using File = mtx::events::RoomEvent<mtx::events::msg::File>;
|
||||
using Image = mtx::events::RoomEvent<mtx::events::msg::Image>;
|
||||
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
||||
using Sticker = mtx::events::Sticker;
|
||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||
using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>;
|
||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||
using ElementEffect = mtx::events::RoomEvent<mtx::events::msg::ElementEffect>;
|
||||
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
||||
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
||||
using CallReject = mtx::events::RoomEvent<mtx::events::voip::CallReject>;
|
||||
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
||||
|
||||
if (std::is_same<T, Audio>::value) {
|
||||
if (isLocal)
|
||||
|
@ -156,14 +156,15 @@ messageDescription(const QString &username = QString(),
|
|||
else
|
||||
return QCoreApplication::translate("message-description sent:", "%1: %2")
|
||||
.arg(username, body);
|
||||
} else if (std::is_same<T, Confetti>::value) {
|
||||
} else if (std::is_same<T, ElementEffect>::value) {
|
||||
if (body.isEmpty()) {
|
||||
// TODO: what is the best way to handle this?
|
||||
if (isLocal)
|
||||
return QCoreApplication::translate("message-description sent:",
|
||||
"You sent some confetti");
|
||||
"You sent a chat effect");
|
||||
else
|
||||
return QCoreApplication::translate("message-description sent:",
|
||||
"%1 sent some confetti")
|
||||
"%1 sent a chat effect")
|
||||
.arg(username);
|
||||
} else {
|
||||
if (isLocal)
|
||||
|
|
|
@ -609,8 +609,9 @@ InputBar::confetti(const QString &body, bool rainbowify)
|
|||
{
|
||||
auto html = utils::markdownToHtml(body, rainbowify);
|
||||
|
||||
mtx::events::msg::Confetti confetti;
|
||||
confetti.body = body.trimmed().toStdString();
|
||||
mtx::events::msg::ElementEffect confetti;
|
||||
confetti.msgtype = "nic.custom.confetti";
|
||||
confetti.body = body.trimmed().toStdString();
|
||||
|
||||
if (html != body.trimmed().toHtmlEscaped() &&
|
||||
ChatPage::instance()->userSettings()->markdown()) {
|
||||
|
|
|
@ -54,9 +54,9 @@ struct RoomEventType
|
|||
return qml_mtx_events::EventType::AudioMessage;
|
||||
}
|
||||
constexpr qml_mtx_events::EventType
|
||||
operator()(const mtx::events::Event<mtx::events::msg::Confetti> &)
|
||||
operator()(const mtx::events::Event<mtx::events::msg::ElementEffect> &)
|
||||
{
|
||||
return qml_mtx_events::EventType::ConfettiMessage;
|
||||
return qml_mtx_events::EventType::ElementEffectMessage;
|
||||
}
|
||||
constexpr qml_mtx_events::EventType
|
||||
operator()(const mtx::events::Event<mtx::events::msg::Emote> &)
|
||||
|
@ -367,7 +367,7 @@ qml_mtx_events::fromRoomEventType(qml_mtx_events::EventType t)
|
|||
return mtx::events::EventType::SpaceChild;
|
||||
/// m.room.message
|
||||
case qml_mtx_events::AudioMessage:
|
||||
case qml_mtx_events::ConfettiMessage:
|
||||
case qml_mtx_events::ElementEffectMessage:
|
||||
case qml_mtx_events::EmoteMessage:
|
||||
case qml_mtx_events::FileMessage:
|
||||
case qml_mtx_events::ImageMessage:
|
||||
|
@ -1091,14 +1091,17 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline)
|
|||
msg.contains("🎉") || msg.contains("🎊")) {
|
||||
needsSpecialEffects_ = true;
|
||||
specialEffects_.setFlag(Confetti);
|
||||
} else if (std::get<RoomEvent<mtx::events::msg::Unknown>>(e).content.msgtype ==
|
||||
"io.element.effect.rainfall") {
|
||||
}
|
||||
} else if (std::holds_alternative<RoomEvent<mtx::events::msg::ElementEffect>>(e)) {
|
||||
if (auto msgtype =
|
||||
std::get<RoomEvent<mtx::events::msg::ElementEffect>>(e).content.msgtype;
|
||||
msgtype == "nic.custom.confetti") {
|
||||
needsSpecialEffects_ = true;
|
||||
specialEffects_.setFlag(Confetti);
|
||||
} else if (msgtype == "io.element.effect.rainfall") {
|
||||
needsSpecialEffects_ = true;
|
||||
specialEffects_.setFlag(Rainfall);
|
||||
}
|
||||
} else if (std::holds_alternative<RoomEvent<mtx::events::msg::Confetti>>(e)) {
|
||||
needsSpecialEffects_ = true;
|
||||
specialEffects_.setFlag(Confetti);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2949,7 +2952,7 @@ TimelineModel::setEdit(const QString &newEdit)
|
|||
if (msgType == mtx::events::MessageType::Text ||
|
||||
msgType == mtx::events::MessageType::Notice ||
|
||||
msgType == mtx::events::MessageType::Emote ||
|
||||
msgType == mtx::events::MessageType::Confetti ||
|
||||
msgType == mtx::events::MessageType::ElementEffect ||
|
||||
msgType == mtx::events::MessageType::Unknown) {
|
||||
auto relInfo = relatedInfo(newEdit);
|
||||
auto editText = relInfo.quoted_body;
|
||||
|
@ -2971,14 +2974,23 @@ TimelineModel::setEdit(const QString &newEdit)
|
|||
|
||||
if (msgType == mtx::events::MessageType::Emote)
|
||||
input()->setText("/me " + editText);
|
||||
else if (msgType == mtx::events::MessageType::Confetti)
|
||||
input()->setText("/confetti " + editText);
|
||||
else if (msgType == mtx::events::MessageType::Unknown) {
|
||||
if (auto u = std::get_if<mtx::events::RoomEvent<mtx::events::msg::Unknown>>(&e);
|
||||
u && u->content.msgtype == "io.element.effect.rainfall")
|
||||
else if (msgType == mtx::events::MessageType::ElementEffect)
|
||||
{
|
||||
auto u =
|
||||
std::get_if<mtx::events::RoomEvent<mtx::events::msg::ElementEffect>>(&e);
|
||||
auto msgtypeString = u ? u->content.msgtype : "";
|
||||
if (msgtypeString == "io.element.effect.rainfall")
|
||||
input()->setText("/rainfall " + editText);
|
||||
else if (msgtypeString == "nic.custom.confetti")
|
||||
input()->setText("/confetti " + editText);
|
||||
else
|
||||
input()->setText(editText);
|
||||
input()->setText("/msgtype " + QString::fromStdString(msgtypeString) + " " +
|
||||
editText);
|
||||
} else if (msgType == mtx::events::MessageType::Unknown) {
|
||||
auto u = std::get_if<mtx::events::RoomEvent<mtx::events::msg::Unknown>>(&e);
|
||||
input()->setText("/msgtype " +
|
||||
(u ? QString::fromStdString(u->content.msgtype) : "") + " " +
|
||||
editText);
|
||||
} else
|
||||
input()->setText(editText);
|
||||
} else {
|
||||
|
|
|
@ -99,7 +99,7 @@ enum EventType
|
|||
Widget,
|
||||
/// m.room.message
|
||||
AudioMessage,
|
||||
ConfettiMessage,
|
||||
ElementEffectMessage,
|
||||
EmoteMessage,
|
||||
FileMessage,
|
||||
ImageMessage,
|
||||
|
|
Loading…
Reference in a new issue