Skip to content
Snippets Groups Projects
Commit 97ca8d0e authored by Konstantinos Sideris's avatar Konstantinos Sideris
Browse files

Remove hardcoded font sizes on the top bars and text input

parent 22d0f50e
No related branches found
No related tags found
No related merge requests found
......@@ -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;
};
......@@ -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);
}
......@@ -72,4 +72,7 @@ private:
LogoutDialog *logoutDialog_;
int logoutButtonSize_;
const float DisplayNameFontRatio = 1.3;
const float UserIdFontRatio = 1.1;
};
......@@ -57,10 +57,14 @@ TextInputWidget::TextInputWidget(QWidget *parent)
send_file_button_->setIcon(send_file_icon);
send_file_button_->setIconSize(QSize(24, 24));
QFont font;
font.setPointSize(this->font().pointSize() * TextFontRatio);
input_ = new FilteredTextEdit(this);
input_->setFixedHeight(45);
input_->setFont(font);
input_->setPlaceholderText(tr("Write a message..."));
input_->setStyleSheet("color: #333333; font-size: 13px; border-radius: 0; padding-top: 10px;");
input_->setStyleSheet("color: #333333; border-radius: 0; padding-top: 10px;");
send_message_button_ = new FlatButton(this);
send_message_button_->setForegroundColor(QColor("#acc7dc"));
......@@ -95,10 +99,10 @@ void TextInputWidget::addSelectedEmoji(const QString &emoji)
QTextCursor cursor = input_->textCursor();
QFont emoji_font("Emoji One");
emoji_font.setPixelSize(18);
emoji_font.setPointSize(this->font().pointSize() * EmojiFontRatio);
QFont text_font("Open Sans");
text_font.setPixelSize(13);
text_font.setPixelSize(this->font().pointSize() * TextFontRatio);
QTextCharFormat charfmt;
charfmt.setFont(emoji_font);
......
......@@ -41,11 +41,18 @@ TopRoomBar::TopRoomBar(QWidget *parent)
text_layout_->setSpacing(0);
text_layout_->setContentsMargins(0, 0, 0, 0);
QFont font;
font.setPointSize(this->font().pointSize() * RoomNameFontRatio);
font.setBold(true);
name_label_ = new QLabel(this);
name_label_->setStyleSheet("font-size: 14px; font-weight: 600;");
name_label_->setFont(font);
font.setBold(false);
font.setPointSize(this->font().pointSize() * RoomDescriptionFontRatio);
topic_label_ = new QLabel(this);
topic_label_->setStyleSheet("font-size: 12px;");
topic_label_->setFont(font);
text_layout_->addWidget(name_label_);
text_layout_->addWidget(topic_label_);
......
......@@ -47,20 +47,21 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
userAvatar_->setBackgroundColor("#f9f9f9");
userAvatar_->setTextColor("#333333");
QFont font;
font.setBold(true);
font.setPointSize(this->font().pointSize() * DisplayNameFontRatio);
displayNameLabel_ = new QLabel(this);
displayNameLabel_->setStyleSheet(
"padding: 0 9px;"
"color: #171919;"
"font-size: 14px;"
"font-weight: 500;"
"margin-bottom: -10px;");
displayNameLabel_->setFont(font);
displayNameLabel_->setStyleSheet("padding: 0 9px; color: #171919; margin-bottom: -10px;");
displayNameLabel_->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
font.setBold(false);
font.setPointSize(this->font().pointSize() * UserIdFontRatio);
userIdLabel_ = new QLabel(this);
userIdLabel_->setStyleSheet(
"padding: 0 8px 8px 8px;"
"color: #555459;"
"font-size: 13px");
userIdLabel_->setFont(font);
userIdLabel_->setStyleSheet("padding: 0 8px 8px 8px; color: #555459;");
userIdLabel_->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
avatarLayout_->addWidget(userAvatar_);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment