Skip to content
This repository has been archived by the owner on Oct 17, 2019. It is now read-only.

Commit

Permalink
Remove pixel value from fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
mujx committed Sep 30, 2018
1 parent d1e08e0 commit 9038c95
Show file tree
Hide file tree
Showing 29 changed files with 77 additions and 108 deletions.
4 changes: 2 additions & 2 deletions src/CommunitiesListItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ CommunitiesListItem::paintEvent(QPaintEvent *)

if (avatar_.isNull()) {
QFont font;
font.setPixelSize(conf::roomlist::fonts::communityBubble);
font.setPointSizeF(font.pointSizeF() * 1.3);
p.setFont(font);

p.drawLetterAvatar(utils::firstChar(resolveName()),
Expand Down Expand Up @@ -142,4 +142,4 @@ CommunitiesListItem::updateTooltip()
QString name = resolveName();
setToolTip(name + tr(" (community)"));
}
}
}
1 change: 0 additions & 1 deletion src/LoginPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ LoginPage::LoginPage(QWidget *parent)
button_layout_->addStretch(1);

QFont font;
font.setPixelSize(conf::fontSize);

error_label_ = new QLabel(this);
error_label_->setFont(font);
Expand Down
3 changes: 1 addition & 2 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ MainWindow::MainWindow(QWidget *parent)

restoreWindowSize();

QFont font("Open Sans");
font.setPixelSize(conf::fontSize);
QFont font;
font.setStyleStrategy(QFont::PreferAntialias);
setFont(font);

Expand Down
2 changes: 1 addition & 1 deletion src/QuickSwitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ QuickSwitcher::QuickSwitcher(QWidget *parent)
setMaximumWidth(450);

QFont font;
font.setPixelSize(20);
font.setPointSizeF(font.pointSizeF() * 1.5);

roomSearch_ = new RoomSearchInput(this);
roomSearch_->setFont(font);
Expand Down
1 change: 0 additions & 1 deletion src/RegisterPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ RegisterPage::RegisterPage(QWidget *parent)
button_layout_->setMargin(0);

QFont font;
font.setPixelSize(conf::fontSize);

error_label_ = new QLabel(this);
error_label_->setFont(font);
Expand Down
12 changes: 4 additions & 8 deletions src/RoomInfoListItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,19 @@ RoomInfoListItem::init(QWidget *parent)
ripple_overlay_->setClipPath(path);
ripple_overlay_->setClipping(true);

font_.setPixelSize(conf::fontSize - 1);

usernameFont_ = font_;
bubbleFont_ = font_;
bubbleFont_.setPointSizeF(font_.pointSizeF() * 1.3);

bubbleFont_ = font_;
bubbleFont_.setPixelSize(conf::roomlist::fonts::bubble);

unreadCountFont_.setPixelSize(conf::roomlist::fonts::badge);
unreadCountFont_.setPointSizeF(font_.pointSizeF() * 0.8);
unreadCountFont_.setBold(true);

bubbleDiameter_ = QFontMetrics(unreadCountFont_).averageCharWidth() * 3;

timestampFont_ = font_;
timestampFont_.setPixelSize(conf::roomlist::fonts::timestamp);
timestampFont_.setBold(false);

headingFont_ = font_;
headingFont_.setPixelSize(conf::roomlist::fonts::heading);
headingFont_.setWeight(60);

menu_ = new Menu(this);
Expand Down
4 changes: 0 additions & 4 deletions src/SuggestionsPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ UserItem::UserItem(QWidget *parent, const QString &user_id)
: PopupItem(parent)
, userId_{user_id}
{
QFont font;
font.setPixelSize(conf::popup::font);

auto displayName = Cache::displayName(ChatPage::instance()->currentRoom(), userId_);

avatar_->setSize(conf::popup::avatar);
Expand All @@ -55,7 +52,6 @@ UserItem::UserItem(QWidget *parent, const QString &user_id)
avatar_->setLetter(QChar(displayName.at(1)));

userName_ = new QLabel(displayName, this);
userName_->setFont(font);

topLayout_->addWidget(avatar_);
topLayout_->addWidget(userName_, 1);
Expand Down
10 changes: 5 additions & 5 deletions src/TopRoomBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TopRoomBar::TopRoomBar(QWidget *parent)
: QWidget(parent)
, buttonSize_{32}
{
setFixedHeight(60);
setFixedHeight(56);

topLayout_ = new QHBoxLayout(this);
topLayout_->setSpacing(8);
Expand All @@ -46,15 +46,15 @@ TopRoomBar::TopRoomBar(QWidget *parent)
textLayout_->setSpacing(0);
textLayout_->setContentsMargins(0, 0, 0, 0);

QFont roomFont("Open Sans SemiBold");
roomFont.setPixelSize(conf::topRoomBar::fonts::roomName);
QFont roomFont;
roomFont.setPointSizeF(roomFont.pointSizeF() * 1.2);
roomFont.setWeight(QFont::Medium);

nameLabel_ = new QLabel(this);
nameLabel_->setFont(roomFont);
nameLabel_->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);

QFont descriptionFont("Open Sans");
descriptionFont.setPixelSize(conf::topRoomBar::fonts::roomDescription);
QFont descriptionFont;

topicLabel_ = new TextLabel(this);
topicLabel_->setLineWrapMode(QTextEdit::NoWrap);
Expand Down
1 change: 0 additions & 1 deletion src/TypingDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ TypingDisplay::TypingDisplay(QWidget *parent)
, offset_{conf::textInput::height}
{
QFont f;
f.setPixelSize(conf::typingNotificationFontSize);
setFont(f);

setFixedHeight(QFontMetrics(font()).height() + RECT_PADDING);
Expand Down
15 changes: 6 additions & 9 deletions src/UserInfoWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,33 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
, user_id_("@user:homeserver.org")
, logoutButtonSize_{20}
{
setFixedHeight(60);
setFixedHeight(56);

topLayout_ = new QHBoxLayout(this);
topLayout_->setSpacing(0);
topLayout_->setMargin(5);

avatarLayout_ = new QHBoxLayout();
textLayout_ = new QVBoxLayout();
textLayout_->setSpacing(2);
textLayout_->setContentsMargins(10, 5, 10, 5);

userAvatar_ = new Avatar(this);
userAvatar_->setObjectName("userAvatar");
userAvatar_->setLetter(QChar('?'));
userAvatar_->setSize(45);

QFont nameFont("Open Sans SemiBold");
nameFont.setPixelSize(conf::userInfoWidget::fonts::displayName);
QFont nameFont;
nameFont.setPointSizeF(nameFont.pointSizeF() * 1.2);
nameFont.setWeight(QFont::Medium);

displayNameLabel_ = new QLabel(this);
displayNameLabel_->setFont(nameFont);
displayNameLabel_->setObjectName("displayNameLabel");
displayNameLabel_->setStyleSheet("padding: 0 9px; margin-bottom: -10px;");
displayNameLabel_->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);

QFont useridFont("Open Sans");
useridFont.setPixelSize(conf::userInfoWidget::fonts::userid);

userIdLabel_ = new QLabel(this);
userIdLabel_->setFont(useridFont);
userIdLabel_->setObjectName("userIdLabel");
userIdLabel_->setStyleSheet("padding: 0 8px 8px 8px;");
userIdLabel_->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);

avatarLayout_->addWidget(userAvatar_);
Expand Down
2 changes: 1 addition & 1 deletion src/UserSettingsPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
encryptionLayout_->addWidget(new HorizontalLine{this});
encryptionLayout_->addLayout(sessionKeysLayout);

font.setWeight(65);
font.setWeight(QFont::Medium);

auto encryptionLabel_ = new QLabel(tr("ENCRYPTION"), this);
encryptionLabel_->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
Expand Down
8 changes: 4 additions & 4 deletions src/dialogs/CreateRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ CreateRoom::CreateRoom(QWidget *parent)
setWindowModality(Qt::WindowModal);
setAttribute(Qt::WA_DeleteOnClose, true);

QFont doubleFont;
doubleFont.setPointSizeF(doubleFont.pointSizeF() * 2);
QFont largeFont;
largeFont.setPointSizeF(largeFont.pointSizeF() * 1.5);

setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
setMinimumHeight(conf::modals::MIN_WIDGET_HEIGHT);
setMinimumWidth(QFontMetrics(doubleFont).averageCharWidth() * 30 -
setMinimumWidth(QFontMetrics(largeFont).averageCharWidth() * 30 -
2 * conf::modals::WIDGET_MARGIN);

auto layout = new QVBoxLayout(this);
Expand All @@ -43,7 +43,7 @@ CreateRoom::CreateRoom(QWidget *parent)
buttonLayout->addWidget(confirmBtn_);

QFont font;
font.setPixelSize(conf::headerFontSize);
font.setPointSizeF(font.pointSizeF() * 1.3);

nameInput_ = new TextField(this);
nameInput_->setLabel(tr("Name"));
Expand Down
6 changes: 3 additions & 3 deletions src/dialogs/MemberList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ MemberList::MemberList(const QString &room_id, QWidget *parent)
list_->setSelectionMode(QAbstractItemView::NoSelection);
list_->setSpacing(5);

QFont doubleFont;
doubleFont.setPointSizeF(doubleFont.pointSizeF() * 2);
QFont largeFont;
largeFont.setPointSizeF(largeFont.pointSizeF() * 1.5);

setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
setMinimumHeight(list_->sizeHint().height() * 2);
setMinimumWidth(std::max(list_->sizeHint().width() + 4 * conf::modals::WIDGET_MARGIN,
QFontMetrics(doubleFont).averageCharWidth() * 30 -
QFontMetrics(largeFont).averageCharWidth() * 30 -
2 * conf::modals::WIDGET_MARGIN));

QFont font;
Expand Down
6 changes: 3 additions & 3 deletions src/dialogs/ReadReceipts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ ReadReceipts::ReadReceipts(QWidget *parent)
userList_->setSelectionMode(QAbstractItemView::NoSelection);
userList_->setSpacing(conf::modals::TEXT_SPACING);

QFont doubleFont;
doubleFont.setPointSizeF(doubleFont.pointSizeF() * 2);
QFont largeFont;
largeFont.setPointSizeF(largeFont.pointSizeF() * 1.5);

setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
setMinimumHeight(userList_->sizeHint().height() * 2);
setMinimumWidth(std::max(userList_->sizeHint().width() + 4 * conf::modals::WIDGET_MARGIN,
QFontMetrics(doubleFont).averageCharWidth() * 30 -
QFontMetrics(largeFont).averageCharWidth() * 30 -
2 * conf::modals::WIDGET_MARGIN));

QFont font;
Expand Down
16 changes: 8 additions & 8 deletions src/dialogs/RoomSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ EditModal::EditModal(const QString &roomId, QWidget *parent)
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
setWindowModality(Qt::WindowModal);

QFont doubleFont;
doubleFont.setPointSizeF(doubleFont.pointSizeF() * 2);
setMinimumWidth(QFontMetrics(doubleFont).averageCharWidth() * 30 - 2 * WIDGET_MARGIN);
QFont largeFont;
largeFont.setPointSizeF(largeFont.pointSizeF() * 1.4);
setMinimumWidth(QFontMetrics(largeFont).averageCharWidth() * 30 - 2 * WIDGET_MARGIN);
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

auto layout = new QVBoxLayout(this);
Expand Down Expand Up @@ -169,18 +169,18 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
setWindowModality(Qt::WindowModal);
setAttribute(Qt::WA_DeleteOnClose, true);

QFont doubleFont;
doubleFont.setPointSizeF(doubleFont.pointSizeF() * 2);
QFont largeFont;
largeFont.setPointSizeF(largeFont.pointSizeF() * 1.5);

setMinimumWidth(QFontMetrics(doubleFont).averageCharWidth() * 30 - 2 * WIDGET_MARGIN);
setMinimumWidth(QFontMetrics(largeFont).averageCharWidth() * 30 - 2 * WIDGET_MARGIN);
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

auto layout = new QVBoxLayout(this);
layout->setSpacing(WIDGET_SPACING);
layout->setContentsMargins(WIDGET_MARGIN, TOP_WIDGET_MARGIN, WIDGET_MARGIN, WIDGET_MARGIN);

QFont font;
font.setWeight(65);
font.setWeight(QFont::Medium);
font.setPointSizeF(font.pointSizeF() * 1.2);
auto settingsLabel = new QLabel(tr("Settings").toUpper(), this);
settingsLabel->setFont(font);
Expand Down Expand Up @@ -356,7 +356,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
}

roomNameLabel_ = new QLabel(QString::fromStdString(info_.name), this);
roomNameLabel_->setFont(doubleFont);
roomNameLabel_->setFont(largeFont);

auto membersLabel = new QLabel(tr("%n member(s)", "", info_.member_count), this);

Expand Down
6 changes: 3 additions & 3 deletions src/dialogs/UserProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ UserProfile::UserProfile(QWidget *parent)
setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
setWindowModality(Qt::WindowModal);

QFont doubleFont;
doubleFont.setPointSizeF(doubleFont.pointSizeF() * 2);
QFont largeFont;
largeFont.setPointSizeF(largeFont.pointSizeF() * 1.5);

setMinimumWidth(
std::max(devices_->sizeHint().width() + 4 * WIDGET_MARGIN,
QFontMetrics(doubleFont).averageCharWidth() * 30 - 2 * WIDGET_MARGIN));
QFontMetrics(largeFont).averageCharWidth() * 30 - 2 * WIDGET_MARGIN));
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

vlayout->setSpacing(WIDGET_SPACING);
Expand Down
4 changes: 2 additions & 2 deletions src/emoji/Category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ Category::Category(QString category, std::vector<Emoji> emoji, QWidget *parent)
itemModel_->appendRow(item);
}

QFont font("Open Sans SemiBold");
font.setPixelSize(conf::fontSize);
QFont font;
font.setWeight(QFont::Medium);

category_ = new QLabel(category, this);
category_->setFont(font);
Expand Down
1 change: 0 additions & 1 deletion src/emoji/ItemDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ ItemDelegate::paint(QPainter *painter,
auto emoji = index.data(Qt::UserRole).toString();

QFont font("Emoji One");
font.setPixelSize(19);

painter->setFont(font);
painter->drawText(viewOption.rect, Qt::AlignCenter, emoji);
Expand Down
22 changes: 8 additions & 14 deletions src/timeline/TimelineItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ TimelineItem::init()
userName_ = nullptr;
body_ = nullptr;

font_.setPixelSize(conf::fontSize);
usernameFont_ = font_;
usernameFont_.setWeight(60);
usernameFont_.setWeight(QFont::Medium);

QFontMetrics fm(font_);

Expand Down Expand Up @@ -216,9 +215,11 @@ TimelineItem::init()
mainLayout_->setContentsMargins(conf::timeline::headerLeftMargin, 0, 0, 0);
mainLayout_->setSpacing(0);

QFont timestampFont;
timestampFont.setPixelSize(conf::timeline::fonts::indicator);
QFontMetrics tsFm(timestampFont);
timestampFont_.setPointSizeF(timestampFont_.pointSizeF() * 0.9);
timestampFont_.setFamily("Monospace");
timestampFont_.setStyleHint(QFont::Monospace);

QFontMetrics tsFm(timestampFont_);

statusIndicator_ = new StatusIndicator(this);
statusIndicator_->setFixedWidth(tsFm.height() - tsFm.leading());
Expand Down Expand Up @@ -662,13 +663,8 @@ TimelineItem::generateUserName(const QString &user_id, const QString &displaynam
void
TimelineItem::generateTimestamp(const QDateTime &time)
{
QFont timestampFont;
timestampFont.setFamily("Monospace");
timestampFont.setStyleHint(QFont::Monospace);
timestampFont.setPixelSize(conf::timeline::fonts::timestamp);

timestamp_ = new QLabel(this);
timestamp_->setFont(timestampFont);
timestamp_->setFont(timestampFont_);
timestamp_->setText(
QString("<span style=\"color: #999\"> %1 </span>").arg(time.toString("HH:mm")));
}
Expand All @@ -683,9 +679,7 @@ TimelineItem::replaceEmoji(const QString &body)
for (auto &code : utf32_string) {
// TODO: Be more precise here.
if (code > 9000)
fmtBody += QString("<span style=\"font-family: Emoji "
"One; font-size: %1px\">")
.arg(conf::emojiSize) +
fmtBody += QString("<span style=\"font-family: Emoji One;\">") +
QString::fromUcs4(&code, 1) + "</span>";
else
fmtBody += QString::fromUcs4(&code, 1);
Expand Down
1 change: 1 addition & 0 deletions src/timeline/TimelineItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class TimelineItem : public QWidget

QFont font_;
QFont usernameFont_;
QFont timestampFont_;

StatusIndicator *statusIndicator_;

Expand Down
1 change: 0 additions & 1 deletion src/timeline/TimelineView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ TimelineView::init()

// Height of the typing display.
QFont f;
f.setPixelSize(conf::typingNotificationFontSize);
const int bottomMargin = QFontMetrics(f).height() + 6;

scroll_layout_ = new QVBoxLayout(scroll_widget_);
Expand Down
Loading

0 comments on commit 9038c95

Please sign in to comment.