mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +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(
|
FetchContent_Declare(
|
||||||
MatrixClient
|
MatrixClient
|
||||||
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
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_EXAMPLES OFF CACHE INTERNAL "")
|
||||||
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
||||||
|
|
|
@ -213,7 +213,7 @@ modules:
|
||||||
buildsystem: cmake-ninja
|
buildsystem: cmake-ninja
|
||||||
name: mtxclient
|
name: mtxclient
|
||||||
sources:
|
sources:
|
||||||
- commit: c8849cd033bb59bee39f3fb2eaca953853731eb2
|
- commit: f8a9cbbb25ea145a23506c2f9386f6c61401bed0
|
||||||
#tag: v0.9.2
|
#tag: v0.9.2
|
||||||
type: git
|
type: git
|
||||||
url: https://github.com/Nheko-Reborn/mtxclient.git
|
url: https://github.com/Nheko-Reborn/mtxclient.git
|
||||||
|
|
|
@ -116,7 +116,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MtxEvent.ConfettiMessage
|
roleValue: MtxEvent.ElementEffectMessage
|
||||||
|
|
||||||
TextMessage {
|
TextMessage {
|
||||||
formatted: d.formattedBody
|
formatted: d.formattedBody
|
||||||
|
|
|
@ -223,7 +223,7 @@ utils::getMessageDescription(const TimelineEvent &event,
|
||||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||||
using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>;
|
using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>;
|
||||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||||
using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>;
|
using ElementEffect = mtx::events::RoomEvent<mtx::events::msg::ElementEffect>;
|
||||||
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||||
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
||||||
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
||||||
|
@ -246,8 +246,8 @@ utils::getMessageDescription(const TimelineEvent &event,
|
||||||
return createDescriptionInfo<Unknown>(event, localUser, displayName);
|
return createDescriptionInfo<Unknown>(event, localUser, displayName);
|
||||||
} else if (std::holds_alternative<Video>(event)) {
|
} else if (std::holds_alternative<Video>(event)) {
|
||||||
return createDescriptionInfo<Video>(event, localUser, displayName);
|
return createDescriptionInfo<Video>(event, localUser, displayName);
|
||||||
} else if (std::holds_alternative<Confetti>(event)) {
|
} else if (std::holds_alternative<ElementEffect>(event)) {
|
||||||
return createDescriptionInfo<Confetti>(event, localUser, displayName);
|
return createDescriptionInfo<ElementEffect>(event, localUser, displayName);
|
||||||
} else if (std::holds_alternative<CallInvite>(event)) {
|
} else if (std::holds_alternative<CallInvite>(event)) {
|
||||||
return createDescriptionInfo<CallInvite>(event, localUser, displayName);
|
return createDescriptionInfo<CallInvite>(event, localUser, displayName);
|
||||||
} else if (std::holds_alternative<CallAnswer>(event)) {
|
} else if (std::holds_alternative<CallAnswer>(event)) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ messageDescription(const QString &username = QString(),
|
||||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||||
using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>;
|
using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>;
|
||||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||||
using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>;
|
using ElementEffect = mtx::events::RoomEvent<mtx::events::msg::ElementEffect>;
|
||||||
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||||
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
||||||
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
||||||
|
@ -156,14 +156,15 @@ messageDescription(const QString &username = QString(),
|
||||||
else
|
else
|
||||||
return QCoreApplication::translate("message-description sent:", "%1: %2")
|
return QCoreApplication::translate("message-description sent:", "%1: %2")
|
||||||
.arg(username, body);
|
.arg(username, body);
|
||||||
} else if (std::is_same<T, Confetti>::value) {
|
} else if (std::is_same<T, ElementEffect>::value) {
|
||||||
if (body.isEmpty()) {
|
if (body.isEmpty()) {
|
||||||
|
// TODO: what is the best way to handle this?
|
||||||
if (isLocal)
|
if (isLocal)
|
||||||
return QCoreApplication::translate("message-description sent:",
|
return QCoreApplication::translate("message-description sent:",
|
||||||
"You sent some confetti");
|
"You sent a chat effect");
|
||||||
else
|
else
|
||||||
return QCoreApplication::translate("message-description sent:",
|
return QCoreApplication::translate("message-description sent:",
|
||||||
"%1 sent some confetti")
|
"%1 sent a chat effect")
|
||||||
.arg(username);
|
.arg(username);
|
||||||
} else {
|
} else {
|
||||||
if (isLocal)
|
if (isLocal)
|
||||||
|
|
|
@ -609,7 +609,8 @@ InputBar::confetti(const QString &body, bool rainbowify)
|
||||||
{
|
{
|
||||||
auto html = utils::markdownToHtml(body, rainbowify);
|
auto html = utils::markdownToHtml(body, rainbowify);
|
||||||
|
|
||||||
mtx::events::msg::Confetti confetti;
|
mtx::events::msg::ElementEffect confetti;
|
||||||
|
confetti.msgtype = "nic.custom.confetti";
|
||||||
confetti.body = body.trimmed().toStdString();
|
confetti.body = body.trimmed().toStdString();
|
||||||
|
|
||||||
if (html != body.trimmed().toHtmlEscaped() &&
|
if (html != body.trimmed().toHtmlEscaped() &&
|
||||||
|
|
|
@ -54,9 +54,9 @@ struct RoomEventType
|
||||||
return qml_mtx_events::EventType::AudioMessage;
|
return qml_mtx_events::EventType::AudioMessage;
|
||||||
}
|
}
|
||||||
constexpr qml_mtx_events::EventType
|
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
|
constexpr qml_mtx_events::EventType
|
||||||
operator()(const mtx::events::Event<mtx::events::msg::Emote> &)
|
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;
|
return mtx::events::EventType::SpaceChild;
|
||||||
/// m.room.message
|
/// m.room.message
|
||||||
case qml_mtx_events::AudioMessage:
|
case qml_mtx_events::AudioMessage:
|
||||||
case qml_mtx_events::ConfettiMessage:
|
case qml_mtx_events::ElementEffectMessage:
|
||||||
case qml_mtx_events::EmoteMessage:
|
case qml_mtx_events::EmoteMessage:
|
||||||
case qml_mtx_events::FileMessage:
|
case qml_mtx_events::FileMessage:
|
||||||
case qml_mtx_events::ImageMessage:
|
case qml_mtx_events::ImageMessage:
|
||||||
|
@ -1091,14 +1091,17 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline)
|
||||||
msg.contains("🎉") || msg.contains("🎊")) {
|
msg.contains("🎉") || msg.contains("🎊")) {
|
||||||
needsSpecialEffects_ = true;
|
needsSpecialEffects_ = true;
|
||||||
specialEffects_.setFlag(Confetti);
|
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;
|
needsSpecialEffects_ = true;
|
||||||
specialEffects_.setFlag(Rainfall);
|
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 ||
|
if (msgType == mtx::events::MessageType::Text ||
|
||||||
msgType == mtx::events::MessageType::Notice ||
|
msgType == mtx::events::MessageType::Notice ||
|
||||||
msgType == mtx::events::MessageType::Emote ||
|
msgType == mtx::events::MessageType::Emote ||
|
||||||
msgType == mtx::events::MessageType::Confetti ||
|
msgType == mtx::events::MessageType::ElementEffect ||
|
||||||
msgType == mtx::events::MessageType::Unknown) {
|
msgType == mtx::events::MessageType::Unknown) {
|
||||||
auto relInfo = relatedInfo(newEdit);
|
auto relInfo = relatedInfo(newEdit);
|
||||||
auto editText = relInfo.quoted_body;
|
auto editText = relInfo.quoted_body;
|
||||||
|
@ -2971,14 +2974,23 @@ TimelineModel::setEdit(const QString &newEdit)
|
||||||
|
|
||||||
if (msgType == mtx::events::MessageType::Emote)
|
if (msgType == mtx::events::MessageType::Emote)
|
||||||
input()->setText("/me " + editText);
|
input()->setText("/me " + editText);
|
||||||
else if (msgType == mtx::events::MessageType::Confetti)
|
else if (msgType == mtx::events::MessageType::ElementEffect)
|
||||||
input()->setText("/confetti " + editText);
|
{
|
||||||
else if (msgType == mtx::events::MessageType::Unknown) {
|
auto u =
|
||||||
if (auto u = std::get_if<mtx::events::RoomEvent<mtx::events::msg::Unknown>>(&e);
|
std::get_if<mtx::events::RoomEvent<mtx::events::msg::ElementEffect>>(&e);
|
||||||
u && u->content.msgtype == "io.element.effect.rainfall")
|
auto msgtypeString = u ? u->content.msgtype : "";
|
||||||
|
if (msgtypeString == "io.element.effect.rainfall")
|
||||||
input()->setText("/rainfall " + editText);
|
input()->setText("/rainfall " + editText);
|
||||||
|
else if (msgtypeString == "nic.custom.confetti")
|
||||||
|
input()->setText("/confetti " + editText);
|
||||||
else
|
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
|
} else
|
||||||
input()->setText(editText);
|
input()->setText(editText);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -99,7 +99,7 @@ enum EventType
|
||||||
Widget,
|
Widget,
|
||||||
/// m.room.message
|
/// m.room.message
|
||||||
AudioMessage,
|
AudioMessage,
|
||||||
ConfettiMessage,
|
ElementEffectMessage,
|
||||||
EmoteMessage,
|
EmoteMessage,
|
||||||
FileMessage,
|
FileMessage,
|
||||||
ImageMessage,
|
ImageMessage,
|
||||||
|
|
Loading…
Reference in a new issue