summary refs log tree commit diff
path: root/src/HistoryViewItem.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/HistoryViewItem.cc')
-rw-r--r--src/HistoryViewItem.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/HistoryViewItem.cc b/src/HistoryViewItem.cc

index 39965e03..ed00abf9 100644 --- a/src/HistoryViewItem.cc +++ b/src/HistoryViewItem.cc
@@ -70,7 +70,7 @@ void HistoryViewItem::generateBody(const QString &body) " </span>" "</body>" "</html>"); - content_label_->setText(content.arg(body)); + content_label_->setText(content.arg(replaceEmoji(body))); content_label_->setTextInteractionFlags(Qt::TextSelectableByMouse); } @@ -94,7 +94,7 @@ void HistoryViewItem::generateBody(const QString &userid, const QString &color, " </span>" "</body>" "</html>"); - content_label_->setText(content.arg(color).arg(sender).arg(body)); + content_label_->setText(content.arg(color).arg(sender).arg(replaceEmoji(body))); content_label_->setTextInteractionFlags(Qt::TextSelectableByMouse); } @@ -137,6 +137,23 @@ void HistoryViewItem::setupLayout() setLayout(top_layout_); } +QString HistoryViewItem::replaceEmoji(const QString &body) +{ + QString fmtBody = ""; + + for (auto &c : body) { + auto code = c.unicode(); + + // TODO: A map should be used with the unicode codes supported by emoji one + if (code > 127) + fmtBody += "<span style=\"font-family: Emoji One; font-size: 16px\">" + QString(c) + "</span>"; + else + fmtBody += c; + } + + return fmtBody; +} + HistoryViewItem::~HistoryViewItem() { }