Fix QML emojis

pull/91/head
Nicolas Werner 5 years ago
parent bbbd5df75f
commit 8727831de7
  1. 3
      resources/qml/TimelineView.qml
  2. 5
      src/Utils.cpp
  3. 6
      src/timeline2/TimelineModel.cpp
  4. 1
      src/timeline2/TimelineModel.h

@ -173,8 +173,9 @@ Rectangle {
Text {
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)
textFormat: Text.RichText
}
}
}

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

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

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

Loading…
Cancel
Save