Fix /me giving extra newline
Make sure that the emote name is added inside the first paragraph rather than as an additional one. Note alternate to network/neochat!632 because I didn'y realise @tfella had done a patch CCBUG: 461837
This commit is contained in:
@@ -460,6 +460,13 @@ QString NeoChatRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format,
|
|||||||
auto base = url.scheme() + QStringLiteral("://") + url.host() + (url.port() != -1 ? ':' + QString::number(url.port()) : QString());
|
auto base = url.scheme() + QStringLiteral("://") + url.host() + (url.port() != -1 ? ':' + QString::number(url.port()) : QString());
|
||||||
htmlBody.replace(utils::mxcImageRegExp, QStringLiteral(R"(<img \1 src="%1/_matrix/media/r0/download/\2/\3" \4 > )").arg(base));
|
htmlBody.replace(utils::mxcImageRegExp, QStringLiteral(R"(<img \1 src="%1/_matrix/media/r0/download/\2/\3" \4 > )").arg(base));
|
||||||
|
|
||||||
|
if (e.msgtype() == MessageEventType::Emote) {
|
||||||
|
auto author = static_cast<NeoChatUser *>(user(e.senderId()));
|
||||||
|
int firstPara = htmlBody.indexOf("<p>");
|
||||||
|
htmlBody.insert(firstPara == -1 ? 0 : firstPara + 3,
|
||||||
|
"* <a href='https://matrix.to/#/" + author->id() + "' style='color: " + author->color().name() + "'>"
|
||||||
|
+ author->displayname(this) + "</a> ");
|
||||||
|
}
|
||||||
return htmlBody;
|
return htmlBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,14 +488,18 @@ QString NeoChatRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format,
|
|||||||
plainBody = e.plainBody();
|
plainBody = e.plainBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prettyPrint) {
|
|
||||||
if (removeReply) {
|
|
||||||
plainBody.remove(utils::removeReplyRegex);
|
|
||||||
}
|
|
||||||
return Quotient::prettyPrint(plainBody);
|
|
||||||
}
|
|
||||||
if (removeReply) {
|
if (removeReply) {
|
||||||
return plainBody.remove(utils::removeReplyRegex);
|
plainBody = plainBody.remove(utils::removeReplyRegex);
|
||||||
|
}
|
||||||
|
if (prettyPrint) {
|
||||||
|
plainBody = Quotient::prettyPrint(plainBody);
|
||||||
|
}
|
||||||
|
if (e.msgtype() == MessageEventType::Emote) {
|
||||||
|
auto author = static_cast<NeoChatUser *>(user(e.senderId()));
|
||||||
|
plainBody.remove("/me");
|
||||||
|
plainBody.insert(0,
|
||||||
|
"* <a href='https://matrix.to/#/" + author->id() + "' style='color: " + author->color().name() + "'>"
|
||||||
|
+ author->displayname(this) + "</a> ");
|
||||||
}
|
}
|
||||||
return plainBody;
|
return plainBody;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ a{
|
|||||||
background: " + Kirigami.Theme.textColor + ";
|
background: " + Kirigami.Theme.textColor + ";
|
||||||
}
|
}
|
||||||
" : "") + "
|
" : "") + "
|
||||||
</style>" + (isEmote ? "* <a href='https://matrix.to/#/" + author.id + "' style='color: " + author.color + "'>" + author.displayName + "</a> " : "") + textMessage + (isEdited ? (" <span style=\"color: " + Kirigami.Theme.disabledTextColor + "\">" + "<span style='font-size: " + Kirigami.Theme.defaultFont.pixelSize +"px'>" + i18n(" (edited)") + "</span>") : "")
|
</style>" + textMessage + (isEdited ? (" <span style=\"color: " + Kirigami.Theme.disabledTextColor + "\">" + "<span style='font-size: " + Kirigami.Theme.defaultFont.pixelSize +"px'>" + i18n(" (edited)") + "</span>") : "")
|
||||||
|
|
||||||
color: Kirigami.Theme.textColor
|
color: Kirigami.Theme.textColor
|
||||||
selectedTextColor: Kirigami.Theme.highlightedTextColor
|
selectedTextColor: Kirigami.Theme.highlightedTextColor
|
||||||
|
|||||||
Reference in New Issue
Block a user