Use span tags to prevent html escaping

This commit is contained in:
Konstantinos Sideris 2017-11-25 14:01:01 +02:00
parent 0f363b5f44
commit f4036f6f56

View file

@ -341,15 +341,12 @@ TimelineItem::generateBody(const QString &userid, const QString &body)
sender = userid.split(":")[0].split("@")[1]; sender = userid.split(":")[0].split("@")[1];
} }
QString userContent("%1");
QString bodyContent("%1");
QFont usernameFont = font_; QFont usernameFont = font_;
usernameFont.setBold(true); usernameFont.setBold(true);
userName_ = new QLabel(this); userName_ = new QLabel(this);
userName_->setFont(usernameFont); userName_->setFont(usernameFont);
userName_->setText(userContent.arg(sender)); userName_->setText(sender);
if (body.isEmpty()) if (body.isEmpty())
return; return;
@ -357,7 +354,7 @@ TimelineItem::generateBody(const QString &userid, const QString &body)
body_ = new QLabel(this); body_ = new QLabel(this);
body_->setFont(font_); body_->setFont(font_);
body_->setWordWrap(true); body_->setWordWrap(true);
body_->setText(bodyContent.arg(replaceEmoji(body))); body_->setText(QString("<span> %1 </span>").arg(replaceEmoji(body)));
body_->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction); body_->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction);
body_->setOpenExternalLinks(true); body_->setOpenExternalLinks(true);
body_->setMargin(0); body_->setMargin(0);
@ -366,8 +363,6 @@ TimelineItem::generateBody(const QString &userid, const QString &body)
void void
TimelineItem::generateTimestamp(const QDateTime &time) TimelineItem::generateTimestamp(const QDateTime &time)
{ {
QString msg("%1");
QFont timestampFont; QFont timestampFont;
timestampFont.setPixelSize(conf::timeline::fonts::timestamp); timestampFont.setPixelSize(conf::timeline::fonts::timestamp);
@ -376,7 +371,7 @@ TimelineItem::generateTimestamp(const QDateTime &time)
timestamp_ = new QLabel(this); timestamp_ = new QLabel(this);
timestamp_->setFont(timestampFont); timestamp_->setFont(timestampFont);
timestamp_->setText(msg.arg(time.toString("HH:mm"))); timestamp_->setText(time.toString("HH:mm"));
timestamp_->setContentsMargins(0, topMargin, 0, 0); timestamp_->setContentsMargins(0, topMargin, 0, 0);
timestamp_->setStyleSheet( timestamp_->setStyleSheet(
QString("font-size: %1px;").arg(conf::timeline::fonts::timestamp)); QString("font-size: %1px;").arg(conf::timeline::fonts::timestamp));