mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Fix QML emojis
This commit is contained in:
parent
bbbd5df75f
commit
8727831de7
4 changed files with 11 additions and 4 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue