diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-04-19 19:38:39 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-04-19 19:38:39 +0300 |
commit | f046dc8ac6b5ea8d3ce93f8fcc1bd4aa300fd83c (patch) | |
tree | 68acb3dc01860968c2e3cc3b5c9b14438d08ea44 | |
parent | Update unread messages for the current room when the app is inactive (diff) | |
download | nheko-f046dc8ac6b5ea8d3ce93f8fcc1bd4aa300fd83c.tar.xz |
Add initial read-only emoji support
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | include/HistoryViewItem.h | 2 | ||||
-rw-r--r-- | resources/fonts/EmojiOne/emojione-android.ttf | bin | 0 -> 3524972 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/LICENSE.txt (renamed from resources/fonts/LICENSE.txt) | 0 | ||||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-Bold.ttf (renamed from resources/fonts/OpenSans-Bold.ttf) | bin | 224592 -> 224592 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-BoldItalic.ttf (renamed from resources/fonts/OpenSans-BoldItalic.ttf) | bin | 213292 -> 213292 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-ExtraBold.ttf (renamed from resources/fonts/OpenSans-ExtraBold.ttf) | bin | 222584 -> 222584 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf (renamed from resources/fonts/OpenSans-ExtraBoldItalic.ttf) | bin | 213420 -> 213420 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-Italic.ttf (renamed from resources/fonts/OpenSans-Italic.ttf) | bin | 212896 -> 212896 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-Light.ttf (renamed from resources/fonts/OpenSans-Light.ttf) | bin | 222412 -> 222412 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-LightItalic.ttf (renamed from resources/fonts/OpenSans-LightItalic.ttf) | bin | 213128 -> 213128 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-Regular.ttf (renamed from resources/fonts/OpenSans-Regular.ttf) | bin | 217360 -> 217360 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-Semibold.ttf (renamed from resources/fonts/OpenSans-Semibold.ttf) | bin | 221328 -> 221328 bytes | |||
-rw-r--r-- | resources/fonts/OpenSans/OpenSans-SemiboldItalic.ttf (renamed from resources/fonts/OpenSans-SemiboldItalic.ttf) | bin | 212820 -> 212820 bytes | |||
-rw-r--r-- | resources/res.qrc | 22 | ||||
-rw-r--r-- | src/HistoryViewItem.cc | 21 | ||||
-rw-r--r-- | src/TextInputWidget.cc | 2 | ||||
-rw-r--r-- | src/main.cc | 1 |
18 files changed, 41 insertions, 12 deletions
diff --git a/README.md b/README.md index eda482ed..6c3fe50c 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,11 @@ Here is a screen shot to get a feel for the UI, but things will probably change. ![nheko](https://dl.dropboxusercontent.com/s/fw94dkpmr7azvmm/nheko.png) +### Third party + +- [Emoji One](http://emojione.com) +- [Open Sans](https://fonts.google.com/specimen/Open+Sans) + ### License diff --git a/include/HistoryViewItem.h b/include/HistoryViewItem.h index e1ed3374..5b54269e 100644 --- a/include/HistoryViewItem.h +++ b/include/HistoryViewItem.h @@ -42,6 +42,8 @@ private: void generateBody(const QString &userid, const QString &color, const QString &body); void generateTimestamp(const QDateTime &time); + QString replaceEmoji(const QString &body); + void setupLayout(); QHBoxLayout *top_layout_; diff --git a/resources/fonts/EmojiOne/emojione-android.ttf b/resources/fonts/EmojiOne/emojione-android.ttf new file mode 100644 index 00000000..4cd640d0 --- /dev/null +++ b/resources/fonts/EmojiOne/emojione-android.ttf Binary files differdiff --git a/resources/fonts/LICENSE.txt b/resources/fonts/OpenSans/LICENSE.txt index d6456956..d6456956 100644 --- a/resources/fonts/LICENSE.txt +++ b/resources/fonts/OpenSans/LICENSE.txt diff --git a/resources/fonts/OpenSans-Bold.ttf b/resources/fonts/OpenSans/OpenSans-Bold.ttf index fd79d43b..fd79d43b 100644 --- a/resources/fonts/OpenSans-Bold.ttf +++ b/resources/fonts/OpenSans/OpenSans-Bold.ttf Binary files differdiff --git a/resources/fonts/OpenSans-BoldItalic.ttf b/resources/fonts/OpenSans/OpenSans-BoldItalic.ttf index 9bc80095..9bc80095 100644 --- a/resources/fonts/OpenSans-BoldItalic.ttf +++ b/resources/fonts/OpenSans/OpenSans-BoldItalic.ttf Binary files differdiff --git a/resources/fonts/OpenSans-ExtraBold.ttf b/resources/fonts/OpenSans/OpenSans-ExtraBold.ttf index 21f6f84a..21f6f84a 100644 --- a/resources/fonts/OpenSans-ExtraBold.ttf +++ b/resources/fonts/OpenSans/OpenSans-ExtraBold.ttf Binary files differdiff --git a/resources/fonts/OpenSans-ExtraBoldItalic.ttf b/resources/fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf index 31cb6883..31cb6883 100644 --- a/resources/fonts/OpenSans-ExtraBoldItalic.ttf +++ b/resources/fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf Binary files differdiff --git a/resources/fonts/OpenSans-Italic.ttf b/resources/fonts/OpenSans/OpenSans-Italic.ttf index c90da48f..c90da48f 100644 --- a/resources/fonts/OpenSans-Italic.ttf +++ b/resources/fonts/OpenSans/OpenSans-Italic.ttf Binary files differdiff --git a/resources/fonts/OpenSans-Light.ttf b/resources/fonts/OpenSans/OpenSans-Light.ttf index 0d381897..0d381897 100644 --- a/resources/fonts/OpenSans-Light.ttf +++ b/resources/fonts/OpenSans/OpenSans-Light.ttf Binary files differdiff --git a/resources/fonts/OpenSans-LightItalic.ttf b/resources/fonts/OpenSans/OpenSans-LightItalic.ttf index 68299c4b..68299c4b 100644 --- a/resources/fonts/OpenSans-LightItalic.ttf +++ b/resources/fonts/OpenSans/OpenSans-LightItalic.ttf Binary files differdiff --git a/resources/fonts/OpenSans-Regular.ttf b/resources/fonts/OpenSans/OpenSans-Regular.ttf index db433349..db433349 100644 --- a/resources/fonts/OpenSans-Regular.ttf +++ b/resources/fonts/OpenSans/OpenSans-Regular.ttf Binary files differdiff --git a/resources/fonts/OpenSans-Semibold.ttf b/resources/fonts/OpenSans/OpenSans-Semibold.ttf index 1a7679e3..1a7679e3 100644 --- a/resources/fonts/OpenSans-Semibold.ttf +++ b/resources/fonts/OpenSans/OpenSans-Semibold.ttf Binary files differdiff --git a/resources/fonts/OpenSans-SemiboldItalic.ttf b/resources/fonts/OpenSans/OpenSans-SemiboldItalic.ttf index 59b6d16b..59b6d16b 100644 --- a/resources/fonts/OpenSans-SemiboldItalic.ttf +++ b/resources/fonts/OpenSans/OpenSans-SemiboldItalic.ttf Binary files differdiff --git a/resources/res.qrc b/resources/res.qrc index 0c1479d8..b90e4fe8 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -14,15 +14,17 @@ </qresource> <qresource prefix="/fonts"> - <file>fonts/OpenSans-Light.ttf</file> - <file>fonts/OpenSans-LightItalic.ttf</file> - <file>fonts/OpenSans-Regular.ttf</file> - <file>fonts/OpenSans-Italic.ttf</file> - <file>fonts/OpenSans-Bold.ttf</file> - <file>fonts/OpenSans-BoldItalic.ttf</file> - <file>fonts/OpenSans-Semibold.ttf</file> - <file>fonts/OpenSans-SemiboldItalic.ttf</file> - <file>fonts/OpenSans-ExtraBold.ttf</file> - <file>fonts/OpenSans-ExtraBoldItalic.ttf</file> + <file>fonts/OpenSans/OpenSans-Light.ttf</file> + <file>fonts/OpenSans/OpenSans-LightItalic.ttf</file> + <file>fonts/OpenSans/OpenSans-Regular.ttf</file> + <file>fonts/OpenSans/OpenSans-Italic.ttf</file> + <file>fonts/OpenSans/OpenSans-Bold.ttf</file> + <file>fonts/OpenSans/OpenSans-BoldItalic.ttf</file> + <file>fonts/OpenSans/OpenSans-Semibold.ttf</file> + <file>fonts/OpenSans/OpenSans-SemiboldItalic.ttf</file> + <file>fonts/OpenSans/OpenSans-ExtraBold.ttf</file> + <file>fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf</file> + + <file>fonts/EmojiOne/emojione-android.ttf</file> </qresource> </RCC> 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() { } diff --git a/src/TextInputWidget.cc b/src/TextInputWidget.cc index d0deee7b..08aa34eb 100644 --- a/src/TextInputWidget.cc +++ b/src/TextInputWidget.cc @@ -24,6 +24,8 @@ TextInputWidget::TextInputWidget(QWidget *parent) : QWidget(parent) { + setFont(QFont("Emoji One")); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setCursor(Qt::ArrowCursor); setStyleSheet("background-color: #f8fbfe; height: 45px;"); diff --git a/src/main.cc b/src/main.cc index d7cb88b3..0a9259c7 100644 --- a/src/main.cc +++ b/src/main.cc @@ -36,6 +36,7 @@ int main(int argc, char *argv[]) QFontDatabase::addApplicationFont(":/fonts/OpenSans-SemiboldItalic.ttf"); QFontDatabase::addApplicationFont(":/fonts/OpenSans-ExtraBold.ttf"); QFontDatabase::addApplicationFont(":/fonts/OpenSans-ExtraBoldItalic.ttf"); + QFontDatabase::addApplicationFont(":/fonts/emojione-android.ttf"); QApplication app(argc, argv); |