mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Make inline images work a bit better
This commit is contained in:
parent
c9393fe3f6
commit
b8c6c716be
1 changed files with 10 additions and 2 deletions
|
@ -362,6 +362,8 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
|
|||
const static QRegularExpression replyFallback(
|
||||
"<mx-reply>.*</mx-reply>", QRegularExpression::DotMatchesEverythingOption);
|
||||
|
||||
auto ascent = QFontMetrics(UserSettings::instance()->font()).ascent();
|
||||
|
||||
bool isReply = relations(event).reply_to().has_value();
|
||||
|
||||
auto formattedBody_ = QString::fromStdString(formatted_body(event));
|
||||
|
@ -380,8 +382,14 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
|
|||
formattedBody_ = formattedBody_.remove(replyFallback);
|
||||
}
|
||||
|
||||
formattedBody_.replace("<img src=\"mxc://", "<img src=\"image://mxcImage/");
|
||||
formattedBody_.replace("<img src=\"mxc://", "<img src=\"image://mxcImage/");
|
||||
// TODO(Nico): Don't parse html with a regex
|
||||
const static QRegularExpression matchImgUri(
|
||||
"(<img [^>]*)src=\"mxc://([^\"]*)\"([^>]*>)");
|
||||
formattedBody_.replace(matchImgUri, "\\1 src=\"image://mxcImage/\\2\"\\3");
|
||||
const static QRegularExpression matchEmoticonHeight(
|
||||
"(<img data-mx-emoticon [^>]*)height=\"([^\"]*)\"([^>]*>)");
|
||||
formattedBody_.replace(matchEmoticonHeight,
|
||||
QString("\\1 height=\"%1\"\\3").arg(ascent));
|
||||
|
||||
return QVariant(utils::replaceEmoji(
|
||||
utils::linkifyMessage(utils::escapeBlacklistedHtml(formattedBody_))));
|
||||
|
|
Loading…
Reference in a new issue