Basic text input in qml
This commit is contained in:
parent
7a74b86340
commit
0bb4885632
10 changed files with 179 additions and 211 deletions
|
|
@ -474,81 +474,6 @@ TimelineViewManager::initWithMessages(const std::vector<QString> &roomIds)
|
|||
addRoom(roomId);
|
||||
}
|
||||
|
||||
void
|
||||
TimelineViewManager::queueTextMessage(const QString &msg)
|
||||
{
|
||||
if (!timeline_)
|
||||
return;
|
||||
|
||||
mtx::events::msg::Text text = {};
|
||||
text.body = msg.trimmed().toStdString();
|
||||
|
||||
if (ChatPage::instance()->userSettings()->markdown()) {
|
||||
text.formatted_body = utils::markdownToHtml(msg).toStdString();
|
||||
|
||||
// Don't send formatted_body, when we don't need to
|
||||
if (text.formatted_body.find("<") == std::string::npos)
|
||||
text.formatted_body = "";
|
||||
else
|
||||
text.format = "org.matrix.custom.html";
|
||||
}
|
||||
|
||||
if (!timeline_->reply().isEmpty()) {
|
||||
auto related = timeline_->relatedInfo(timeline_->reply());
|
||||
|
||||
QString body;
|
||||
bool firstLine = true;
|
||||
for (const auto &line : related.quoted_body.split("\n")) {
|
||||
if (firstLine) {
|
||||
firstLine = false;
|
||||
body = QString("> <%1> %2\n").arg(related.quoted_user).arg(line);
|
||||
} else {
|
||||
body = QString("%1\n> %2\n").arg(body).arg(line);
|
||||
}
|
||||
}
|
||||
|
||||
text.body = QString("%1\n%2").arg(body).arg(msg).toStdString();
|
||||
|
||||
// NOTE(Nico): rich replies always need a formatted_body!
|
||||
text.format = "org.matrix.custom.html";
|
||||
if (ChatPage::instance()->userSettings()->markdown())
|
||||
text.formatted_body =
|
||||
utils::getFormattedQuoteBody(related, utils::markdownToHtml(msg))
|
||||
.toStdString();
|
||||
else
|
||||
text.formatted_body =
|
||||
utils::getFormattedQuoteBody(related, msg.toHtmlEscaped()).toStdString();
|
||||
|
||||
text.relates_to.in_reply_to.event_id = related.related_event;
|
||||
timeline_->resetReply();
|
||||
}
|
||||
|
||||
timeline_->sendMessageEvent(text, mtx::events::EventType::RoomMessage);
|
||||
}
|
||||
|
||||
void
|
||||
TimelineViewManager::queueEmoteMessage(const QString &msg)
|
||||
{
|
||||
auto html = utils::markdownToHtml(msg);
|
||||
|
||||
mtx::events::msg::Emote emote;
|
||||
emote.body = msg.trimmed().toStdString();
|
||||
|
||||
if (html != msg.trimmed().toHtmlEscaped() &&
|
||||
ChatPage::instance()->userSettings()->markdown()) {
|
||||
emote.formatted_body = html.toStdString();
|
||||
emote.format = "org.matrix.custom.html";
|
||||
}
|
||||
|
||||
if (!timeline_->reply().isEmpty()) {
|
||||
emote.relates_to.in_reply_to.event_id = timeline_->reply().toStdString();
|
||||
timeline_->resetReply();
|
||||
}
|
||||
|
||||
if (timeline_)
|
||||
timeline_->sendMessageEvent(emote, mtx::events::EventType::RoomMessage);
|
||||
}
|
||||
|
||||
void
|
||||
TimelineViewManager::queueReactionMessage(const QString &reactedEvent, const QString &reactionKey)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue