From 97ca8d0ed109dc2be80e459e4b2a4dbafa1aced8 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 1 Jul 2017 15:52:46 +0300 Subject: Remove hardcoded font sizes on the top bars and text input --- include/TopRoomBar.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/TopRoomBar.h') diff --git a/include/TopRoomBar.h b/include/TopRoomBar.h index 6e4bfe7a..ad246090 100644 --- a/include/TopRoomBar.h +++ b/include/TopRoomBar.h @@ -68,6 +68,9 @@ private: Avatar *avatar_; int buttonSize_; + + const float RoomNameFontRatio = 1.2; + const float RoomDescriptionFontRatio = 1; }; inline void TopRoomBar::updateRoomAvatar(const QImage &avatar_image) @@ -82,10 +85,14 @@ inline void TopRoomBar::updateRoomAvatar(const QIcon &icon) inline void TopRoomBar::updateRoomName(const QString &name) { - name_label_->setText(name); + QString elidedText = QFontMetrics(name_label_->font()) + .elidedText(name, Qt::ElideRight, width() * 0.8); + name_label_->setText(elidedText); } inline void TopRoomBar::updateRoomTopic(const QString &topic) { - topic_label_->setText(topic); + QString elidedText = QFontMetrics(topic_label_->font()) + .elidedText(topic, Qt::ElideRight, width() * 0.8); + topic_label_->setText(elidedText); } -- cgit 1.5.1