Fix bug with emoji font setting and clean linting

This commit is contained in:
Joseph Donofry 2019-07-26 17:44:44 -04:00
parent 778921be8a
commit 86888ee713
No known key found for this signature in database
GPG key ID: E8A1D78EF044B0CB
8 changed files with 42 additions and 41 deletions

View file

@ -26,6 +26,29 @@ utils::localUser()
return settings.value("auth/user_id").toString();
}
QString
utils::replaceEmoji(const QString &body)
{
QString fmtBody = "";
QVector<uint> utf32_string = body.toUcs4();
QSettings settings;
QString userFontFamily = settings.value("user/emoji_font_family", "emoji").toString();
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>";
else
fmtBody += QString::fromUcs4(&code, 1);
}
return fmtBody;
}
void
utils::setScaleFactor(float factor)
{