summary refs log tree commit diff
path: root/src/HistoryViewItem.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-19 19:38:39 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-19 19:38:39 +0300
commitf046dc8ac6b5ea8d3ce93f8fcc1bd4aa300fd83c (patch)
tree68acb3dc01860968c2e3cc3b5c9b14438d08ea44 /src/HistoryViewItem.cc
parentUpdate unread messages for the current room when the app is inactive (diff)
downloadnheko-f046dc8ac6b5ea8d3ce93f8fcc1bd4aa300fd83c.tar.xz
Add initial read-only emoji support
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() { }