Add initial read-only emoji support

remotes/origin/HEAD
Konstantinos Sideris 8 years ago
parent e680865593
commit f046dc8ac6
  1. 5
      README.md
  2. 2
      include/HistoryViewItem.h
  3. BIN
      resources/fonts/EmojiOne/emojione-android.ttf
  4. 0
      resources/fonts/OpenSans/LICENSE.txt
  5. 0
      resources/fonts/OpenSans/OpenSans-Bold.ttf
  6. 0
      resources/fonts/OpenSans/OpenSans-BoldItalic.ttf
  7. 0
      resources/fonts/OpenSans/OpenSans-ExtraBold.ttf
  8. 0
      resources/fonts/OpenSans/OpenSans-ExtraBoldItalic.ttf
  9. 0
      resources/fonts/OpenSans/OpenSans-Italic.ttf
  10. 0
      resources/fonts/OpenSans/OpenSans-Light.ttf
  11. 0
      resources/fonts/OpenSans/OpenSans-LightItalic.ttf
  12. 0
      resources/fonts/OpenSans/OpenSans-Regular.ttf
  13. 0
      resources/fonts/OpenSans/OpenSans-Semibold.ttf
  14. 0
      resources/fonts/OpenSans/OpenSans-SemiboldItalic.ttf
  15. 22
      resources/res.qrc
  16. 21
      src/HistoryViewItem.cc
  17. 2
      src/TextInputWidget.cc
  18. 1
      src/main.cc

@ -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

@ -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_;

@ -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>

@ -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()
{
}

@ -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;");

@ -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);

Loading…
Cancel
Save