summary refs log tree commit diff
path: root/src/Utils.cpp
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-06-09 20:51:36 -0400
committerJoseph Donofry <joedonofry@gmail.com>2020-06-09 20:51:36 -0400
commit6bb73f84a3075abe7a1c1fd2d56a259740070c70 (patch)
treeeecb0bc3ec18a04cd226d1caea74b2b65ef6d851 /src/Utils.cpp
parentMinor adjustments to emoji picker (diff)
parentSmooth scaling for images (diff)
downloadnheko-6bb73f84a3075abe7a1c1fd2d56a259740070c70.tar.xz
Merge master and fix conflicts
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r--src/Utils.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp

index 7f11a8cd..26ea124c 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp
@@ -51,6 +51,14 @@ utils::localUser() return QString::fromStdString(http::client()->user_id().to_string()); } +bool +utils::codepointIsEmoji(uint code) +{ + // TODO: Be more precise here. + return (code >= 0x2600 && code <= 0x27bf) || (code >= 0x1f300 && code <= 0x1f3ff) || + (code >= 0x1f000 && code <= 0x1faff); +} + QString utils::replaceEmoji(const QString &body) { @@ -63,9 +71,7 @@ utils::replaceEmoji(const QString &body) bool insideFontBlock = false; for (auto &code : utf32_string) { - // TODO: Be more precise here. - if ((code >= 0x2600 && code <= 0x27bf) || (code >= 0x1f300 && code <= 0x1f3ff) || - (code >= 0x1f000 && code <= 0x1faff)) { + if (utils::codepointIsEmoji(code)) { if (!insideFontBlock) { fmtBody += QString("<font face=\"" + userFontFamily + "\">"); insideFontBlock = true; @@ -136,13 +142,13 @@ utils::descriptiveTime(const QDateTime &then) const auto days = then.daysTo(now); if (days == 0) - return then.time().toString(Qt::DefaultLocaleShortDate); + return QLocale::system().toString(then.time(), QLocale::ShortFormat); else if (days < 2) return QString(QCoreApplication::translate("descriptiveTime", "Yesterday")); else if (days < 7) return then.toString("dddd"); - return then.date().toString(Qt::DefaultLocaleShortDate); + return QLocale::system().toString(then.date(), QLocale::ShortFormat); } DescInfo