diff --git a/README.md b/README.md index eda482e..6c3fe50 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 e1ed337..5b54269 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 0000000..4cd640d Binary files /dev/null and b/resources/fonts/EmojiOne/emojione-android.ttf differ diff --git a/resources/fonts/LICENSE.txt b/resources/fonts/OpenSans/LICENSE.txt similarity index 100% rename from resources/fonts/LICENSE.txt rename to resources/fonts/OpenSans/LICENSE.txt diff --git a/resources/fonts/OpenSans-Bold.ttf b/resources/fonts/OpenSans/OpenSans-Bold.ttf similarity index 100% rename from resources/fonts/OpenSans-Bold.ttf rename to resources/fonts/OpenSans/OpenSans-Bold.ttf diff --git a/resources/fonts/OpenSans-BoldItalic.ttf b/resources/fonts/OpenSans/OpenSans-BoldItalic.ttf similarity index 100% rename from resources/fonts/OpenSans-BoldItalic.ttf rename to resources/fonts/OpenSans/OpenSans-BoldItalic.ttf diff --git a/resources/fonts/OpenSans-ExtraBold.ttf b/resources/fonts/OpenSans/OpenSans-ExtraBold.ttf similarity index 100% rename from resources/fonts/OpenSans-ExtraBold.ttf rename to resources/fonts/OpenSans/OpenSans-ExtraBold.ttf diff --git a/resources/fonts/OpenSans-ExtraBoldItalic.ttf b/resources/fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf similarity index 100% rename from resources/fonts/OpenSans-ExtraBoldItalic.ttf rename to resources/fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf diff --git a/resources/fonts/OpenSans-Italic.ttf b/resources/fonts/OpenSans/OpenSans-Italic.ttf similarity index 100% rename from resources/fonts/OpenSans-Italic.ttf rename to resources/fonts/OpenSans/OpenSans-Italic.ttf diff --git a/resources/fonts/OpenSans-Light.ttf b/resources/fonts/OpenSans/OpenSans-Light.ttf similarity index 100% rename from resources/fonts/OpenSans-Light.ttf rename to resources/fonts/OpenSans/OpenSans-Light.ttf diff --git a/resources/fonts/OpenSans-LightItalic.ttf b/resources/fonts/OpenSans/OpenSans-LightItalic.ttf similarity index 100% rename from resources/fonts/OpenSans-LightItalic.ttf rename to resources/fonts/OpenSans/OpenSans-LightItalic.ttf diff --git a/resources/fonts/OpenSans-Regular.ttf b/resources/fonts/OpenSans/OpenSans-Regular.ttf similarity index 100% rename from resources/fonts/OpenSans-Regular.ttf rename to resources/fonts/OpenSans/OpenSans-Regular.ttf diff --git a/resources/fonts/OpenSans-Semibold.ttf b/resources/fonts/OpenSans/OpenSans-Semibold.ttf similarity index 100% rename from resources/fonts/OpenSans-Semibold.ttf rename to resources/fonts/OpenSans/OpenSans-Semibold.ttf diff --git a/resources/fonts/OpenSans-SemiboldItalic.ttf b/resources/fonts/OpenSans/OpenSans-SemiboldItalic.ttf similarity index 100% rename from resources/fonts/OpenSans-SemiboldItalic.ttf rename to resources/fonts/OpenSans/OpenSans-SemiboldItalic.ttf diff --git a/resources/res.qrc b/resources/res.qrc index 0c1479d..b90e4fe 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -14,15 +14,17 @@ - fonts/OpenSans-Light.ttf - fonts/OpenSans-LightItalic.ttf - fonts/OpenSans-Regular.ttf - fonts/OpenSans-Italic.ttf - fonts/OpenSans-Bold.ttf - fonts/OpenSans-BoldItalic.ttf - fonts/OpenSans-Semibold.ttf - fonts/OpenSans-SemiboldItalic.ttf - fonts/OpenSans-ExtraBold.ttf - fonts/OpenSans-ExtraBoldItalic.ttf + fonts/OpenSans/OpenSans-Light.ttf + fonts/OpenSans/OpenSans-LightItalic.ttf + fonts/OpenSans/OpenSans-Regular.ttf + fonts/OpenSans/OpenSans-Italic.ttf + fonts/OpenSans/OpenSans-Bold.ttf + fonts/OpenSans/OpenSans-BoldItalic.ttf + fonts/OpenSans/OpenSans-Semibold.ttf + fonts/OpenSans/OpenSans-SemiboldItalic.ttf + fonts/OpenSans/OpenSans-ExtraBold.ttf + fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf + + fonts/EmojiOne/emojione-android.ttf diff --git a/src/HistoryViewItem.cc b/src/HistoryViewItem.cc index 39965e0..ed00abf 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() { } diff --git a/src/TextInputWidget.cc b/src/TextInputWidget.cc index d0deee7..08aa34e 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 d7cb88b..0a9259c 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);