From 0ed23506646ff2b8cbd5b99ebce22745740a80da Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 1 Jul 2017 14:03:00 +0300 Subject: [PATCH] Set emoji size relative to the default font --- include/TimelineItem.h | 3 +++ src/TimelineItem.cc | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/TimelineItem.h b/include/TimelineItem.h index ccba27ad..6fd26f52 100644 --- a/include/TimelineItem.h +++ b/include/TimelineItem.h @@ -73,6 +73,9 @@ private: const int AvatarSize = 36; const float TimestampFontRatio = 0.8; + const float EmojiFontRatio = 1.4; + + float EmojiSize = 13; Avatar *userAvatar_; diff --git a/src/TimelineItem.cc b/src/TimelineItem.cc index 12ebcfde..66c55f0c 100644 --- a/src/TimelineItem.cc +++ b/src/TimelineItem.cc @@ -44,6 +44,8 @@ void TimelineItem::init() const int baseWidth = fm.width('A'); MessageMargin = baseWidth * 1.5; + EmojiSize = this->font().pointSize() * EmojiFontRatio; + topLayout_ = new QHBoxLayout(this); sideLayout_ = new QVBoxLayout(); mainLayout_ = new QVBoxLayout(); @@ -289,7 +291,9 @@ QString TimelineItem::replaceEmoji(const QString &body) // TODO: Be more precise here. if (code > 9000) - fmtBody += "" + QString(c) + ""; + fmtBody += QString("").arg(EmojiSize) + + QString(c) + + ""; else fmtBody += c; }