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/TextInputWidget.h | 3 +++ include/TopRoomBar.h | 11 +++++++++-- include/UserInfoWidget.h | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/TextInputWidget.h b/include/TextInputWidget.h index 225750f2..e176d48c 100644 --- a/include/TextInputWidget.h +++ b/include/TextInputWidget.h @@ -63,4 +63,7 @@ private: FlatButton *send_file_button_; FlatButton *send_message_button_; EmojiPickButton *emoji_button_; + + const float TextFontRatio = 1.1; + const float EmojiFontRatio = 1.3; }; 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); } diff --git a/include/UserInfoWidget.h b/include/UserInfoWidget.h index 10c770d8..35f7a6f5 100644 --- a/include/UserInfoWidget.h +++ b/include/UserInfoWidget.h @@ -72,4 +72,7 @@ private: LogoutDialog *logoutDialog_; int logoutButtonSize_; + + const float DisplayNameFontRatio = 1.3; + const float UserIdFontRatio = 1.1; }; -- cgit 1.5.1