summary refs log tree commit diff
path: root/src/timeline/TimelineItem.cpp
diff options
context:
space:
mode:
authorredsky17 <joedonofry@gmail.com>2019-01-26 18:17:08 +0000
committerredsky17 <joedonofry@gmail.com>2019-01-26 18:17:08 +0000
commitdf5d24c87f46f42b8bc73710bcdcb1a3f5f27b49 (patch)
tree1a82673a6e345bfa651def94687fc9f8539795c6 /src/timeline/TimelineItem.cpp
parentFix lint issues in last commit (diff)
downloadnheko-df5d24c87f46f42b8bc73710bcdcb1a3f5f27b49.tar.xz
Revert "Remove built-in emoji picker"
This reverts commit 4b807229aa20d6f4891e35f08d489da427d3d0b6.
Diffstat (limited to 'src/timeline/TimelineItem.cpp')
-rw-r--r--src/timeline/TimelineItem.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/timeline/TimelineItem.cpp b/src/timeline/TimelineItem.cpp

index a0a1759e..8d2343d0 100644 --- a/src/timeline/TimelineItem.cpp +++ b/src/timeline/TimelineItem.cpp
@@ -595,7 +595,7 @@ TimelineItem::markReceived(bool isEncrypted) void TimelineItem::generateBody(const QString &body) { - body_ = new TextLabel(body, this); + body_ = new TextLabel(replaceEmoji(body), this); body_->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction); connect(body_, &TextLabel::userProfileTriggered, this, [](const QString &user_id) { @@ -698,6 +698,25 @@ TimelineItem::generateTimestamp(const QDateTime &time) QString("<span style=\"color: #999\"> %1 </span>").arg(time.toString("HH:mm"))); } +QString +TimelineItem::replaceEmoji(const QString &body) +{ + QString fmtBody = ""; + + QVector<uint> utf32_string = body.toUcs4(); + + for (auto &code : utf32_string) { + // TODO: Be more precise here. + if (code > 9000) + fmtBody += QString("<span style=\"font-family: Emoji One;\">") + + QString::fromUcs4(&code, 1) + "</span>"; + else + fmtBody += QString::fromUcs4(&code, 1); + } + + return fmtBody; +} + void TimelineItem::setupAvatarLayout(const QString &userName) {