summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2019-07-26 17:44:44 -0400
committerJoseph Donofry <joedonofry@gmail.com>2019-07-26 17:44:44 -0400
commit86888ee71349cb416e79940e3b369e047cf7492a (patch)
treee9c933a706b4268458b655b349b52bf6df002c89 /src/timeline
parentAdd emoji text selection option for non-mac (diff)
downloadnheko-86888ee71349cb416e79940e3b369e047cf7492a.tar.xz
Fix bug with emoji font setting and clean linting
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/TimelineItem.cpp27
-rw-r--r--src/timeline/TimelineItem.h1
2 files changed, 2 insertions, 26 deletions
diff --git a/src/timeline/TimelineItem.cpp b/src/timeline/TimelineItem.cpp
index cf5d68c6..54011279 100644
--- a/src/timeline/TimelineItem.cpp
+++ b/src/timeline/TimelineItem.cpp
@@ -650,7 +650,7 @@ TimelineItem::markReceived(bool isEncrypted)
 void
 TimelineItem::generateBody(const QString &body)
 {
-        body_ = new TextLabel(replaceEmoji(body), this);
+        body_ = new TextLabel(utils::replaceEmoji(body), this);
         body_->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction);
 
         connect(body_, &TextLabel::userProfileTriggered, this, [](const QString &user_id) {
@@ -727,7 +727,7 @@ TimelineItem::generateUserName(const QString &user_id, const QString &displaynam
 
         userName_ = new QLabel(this);
         userName_->setFont(usernameFont);
-        userName_->setText(replaceEmoji(fm.elidedText(sender, Qt::ElideRight, 500)));
+        userName_->setText(utils::replaceEmoji(fm.elidedText(sender, Qt::ElideRight, 500)));
         userName_->setToolTip(user_id);
         userName_->setToolTipDuration(1500);
         userName_->setAttribute(Qt::WA_Hover);
@@ -773,29 +773,6 @@ 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();
-
-        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
 TimelineItem::setupAvatarLayout(const QString &userName)
 {
diff --git a/src/timeline/TimelineItem.h b/src/timeline/TimelineItem.h
index e2b1cda4..c0dab6b8 100644
--- a/src/timeline/TimelineItem.h
+++ b/src/timeline/TimelineItem.h
@@ -276,7 +276,6 @@ private:
 
         QFutureWatcher<QString> *colorGenerating_;
 
-        QString replaceEmoji(const QString &body);
         QString event_id_;
         mtx::events::MessageType message_type_;
         QString room_id_;