RecentEmojiPack &cGetRecentEmojis() { if (cRecentEmojis().isEmpty()) { RecentEmojiPack r; if (!cRecentEmojisPreload().isEmpty()) { RecentEmojisPreload p(cRecentEmojisPreload()); cSetRecentEmojisPreload(RecentEmojisPreload()); r.reserve(p.size()); for (RecentEmojisPreload::const_iterator i = p.cbegin(), e = p.cend(); i != e; ++i) { uint64 code = ((!(i->first & 0xFFFFFFFF00000000LLU) && (i->first & 0xFFFFU) == 0xFE0FU)) ? ((i->first >> 16) & 0xFFFFU) : i->first; EmojiPtr ep(emojiFromKey(code)); if (!ep) continue; if (ep->postfix) { int32 j = 0, l = r.size(); for (; j < l; ++j) { if (emojiKey(r[j].first) == code) { break; } } if (j < l) { continue; } } r.push_back(qMakePair(ep, i->second)); } }
void InputField::insertEmoji(EmojiPtr emoji, QTextCursor c) { QTextImageFormat imageFormat; int32 ew = ESize + st::emojiPadding * cIntRetinaFactor() * 2, eh = _st->font->height * cIntRetinaFactor(); imageFormat.setWidth(ew / cIntRetinaFactor()); imageFormat.setHeight(eh / cIntRetinaFactor()); imageFormat.setName(qsl("emoji://e.") + QString::number(emojiKey(emoji), 16)); imageFormat.setVerticalAlignment(QTextCharFormat::AlignBaseline); static QString objectReplacement(QChar::ObjectReplacementCharacter); c.insertText(objectReplacement, imageFormat); }
void FlatTextarea::insertEmoji(EmojiPtr emoji, QTextCursor c) { c.removeSelectedText(); QPixmap img(App::emojiSingle(emoji, _st.font->height)); QString url = qsl("emoji://e.") + QString::number(emojiKey(emoji), 16); document()->addResource(QTextDocument::ImageResource, QUrl(url), QVariant(img)); QTextImageFormat imageFormat; imageFormat.setWidth(img.width() / cIntRetinaFactor()); imageFormat.setHeight(img.height() / cIntRetinaFactor()); imageFormat.setName(url); imageFormat.setVerticalAlignment(QTextCharFormat::AlignBaseline); c.insertImage(imageFormat); }