Fix QML emojis

This commit is contained in:
Nicolas Werner 2019-09-07 02:01:44 +02:00
parent bbbd5df75f
commit 8727831de7
4 changed files with 11 additions and 4 deletions

View file

@ -173,8 +173,9 @@ Rectangle {
Text { Text {
id: userName id: userName
text: chat.model.displayName(section.split(" ")[0]) text: chat.model.escapeEmoji(chat.model.displayName(section.split(" ")[0]))
color: chat.model.userColor(section.split(" ")[0], colors.window) color: chat.model.userColor(section.split(" ")[0], colors.window)
textFormat: Text.RichText
} }
} }
} }

View file

@ -40,9 +40,8 @@ utils::replaceEmoji(const QString &body)
for (auto &code : utf32_string) { for (auto &code : utf32_string) {
// TODO: Be more precise here. // TODO: Be more precise here.
if (code > 9000) if (code > 9000)
fmtBody += fmtBody += QString("<font face=\"" + userFontFamily + "\">") +
QString("<span style=\"font-family: " + userFontFamily + ";\">") + QString::fromUcs4(&code, 1) + "</font>";
QString::fromUcs4(&code, 1) + "</span>";
else else
fmtBody += QString::fromUcs4(&code, 1); fmtBody += QString::fromUcs4(&code, 1);
} }

View file

@ -336,3 +336,9 @@ TimelineModel::formatDateSeparator(QDate date) const
return date.toString(fmt); return date.toString(fmt);
} }
QString
TimelineModel::escapeEmoji(QString str) const
{
return utils::replaceEmoji(str);
}

View file

@ -91,6 +91,7 @@ public:
Q_INVOKABLE QColor userColor(QString id, QColor background); Q_INVOKABLE QColor userColor(QString id, QColor background);
Q_INVOKABLE QString displayName(QString id) const; Q_INVOKABLE QString displayName(QString id) const;
Q_INVOKABLE QString formatDateSeparator(QDate date) const; Q_INVOKABLE QString formatDateSeparator(QDate date) const;
Q_INVOKABLE QString escapeEmoji(QString str) const;
void addEvents(const mtx::responses::Timeline &events); void addEvents(const mtx::responses::Timeline &events);