mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
Add initial read-only emoji support
This commit is contained in:
parent
e680865593
commit
f046dc8ac6
18 changed files with 41 additions and 12 deletions
|
@ -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_;
|
||||
|
|
BIN
resources/fonts/EmojiOne/emojione-android.ttf
Normal file
BIN
resources/fonts/EmojiOne/emojione-android.ttf
Normal file
Binary file not shown.
|
@ -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…
Reference in a new issue