From f046dc8ac6b5ea8d3ce93f8fcc1bd4aa300fd83c Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Wed, 19 Apr 2017 19:38:39 +0300 Subject: Add initial read-only emoji support --- src/HistoryViewItem.cc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/HistoryViewItem.cc') 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) " " "" ""); - 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, " " "" ""); - 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 += "" + QString(c) + ""; + else + fmtBody += c; + } + + return fmtBody; +} + HistoryViewItem::~HistoryViewItem() { } -- cgit 1.5.1