From 8299a74775bcdf917d58038fd35b2fdd208d4154 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Thu, 19 Oct 2017 19:04:51 +0300 Subject: Elide room topic --- src/TopRoomBar.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/TopRoomBar.cc b/src/TopRoomBar.cc index 5a1f2d25..8b2e338b 100644 --- a/src/TopRoomBar.cc +++ b/src/TopRoomBar.cc @@ -71,9 +71,8 @@ TopRoomBar::TopRoomBar(QWidget *parent) settingsBtn_->setIconSize(QSize(buttonSize_ / 2, buttonSize_ / 2)); topLayout_->addWidget(avatar_); - topLayout_->addLayout(textLayout_); - topLayout_->addStretch(1); - topLayout_->addWidget(settingsBtn_); + topLayout_->addLayout(textLayout_, 1); + topLayout_->addWidget(settingsBtn_, 0, Qt::AlignRight); menu_ = new Menu(this); @@ -149,6 +148,9 @@ TopRoomBar::reset() nameLabel_->setText(""); topicLabel_->setText(""); avatar_->setLetter(QChar('?')); + + roomName_.clear(); + roomTopic_.clear(); } void @@ -161,6 +163,14 @@ TopRoomBar::paintEvent(QPaintEvent *event) QPainter painter(this); style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this); + + QString elidedText = + QFontMetrics(nameLabel_->font()).elidedText(roomName_, Qt::ElideRight, width()); + nameLabel_->setText(elidedText); + + elidedText = + QFontMetrics(topicLabel_->font()).elidedText(roomTopic_, Qt::ElideRight, width()); + topicLabel_->setText(elidedText); } void -- cgit 1.5.1