mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Remove pixel value from fonts
This commit is contained in:
parent
d1e08e0008
commit
9038c950ae
29 changed files with 77 additions and 108 deletions
|
@ -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()),
|
||||
|
@ -142,4 +142,4 @@ CommunitiesListItem::updateTooltip()
|
|||
QString name = resolveName();
|
||||
setToolTip(name + tr(" (community)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
@ -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);
|
||||
|
|
|
@ -32,7 +32,7 @@ TopRoomBar::TopRoomBar(QWidget *parent)
|
|||
: QWidget(parent)
|
||||
, buttonSize_{32}
|
||||
{
|
||||
setFixedHeight(60);
|
||||
setFixedHeight(56);
|
||||
|
||||
topLayout_ = new QHBoxLayout(this);
|
||||
topLayout_->setSpacing(8);
|
||||
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -30,7 +30,7 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
|
|||
, user_id_("@user:homeserver.org")
|
||||
, logoutButtonSize_{20}
|
||||
{
|
||||
setFixedHeight(60);
|
||||
setFixedHeight(56);
|
||||
|
||||
topLayout_ = new QHBoxLayout(this);
|
||||
topLayout_->setSpacing(0);
|
||||
|
@ -38,28 +38,25 @@ UserInfoWidget::UserInfoWidget(QWidget *parent)
|
|||
|
||||
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_);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
@ -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"));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
@ -169,10 +169,10 @@ 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);
|
||||
|
@ -180,7 +180,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
|||
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);
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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_);
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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")));
|
||||
}
|
||||
|
@ -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);
|
||||
|
|
|
@ -278,6 +278,7 @@ private:
|
|||
|
||||
QFont font_;
|
||||
QFont usernameFont_;
|
||||
QFont timestampFont_;
|
||||
|
||||
StatusIndicator *statusIndicator_;
|
||||
|
||||
|
|
|
@ -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_);
|
||||
|
|
|
@ -159,8 +159,7 @@ void
|
|||
AudioItem::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(12);
|
||||
font.setWeight(80);
|
||||
font.setWeight(QFont::Medium);
|
||||
|
||||
QFontMetrics fm(font);
|
||||
const int computedWidth = std::min(
|
||||
|
@ -180,8 +179,7 @@ AudioItem::paintEvent(QPaintEvent *event)
|
|||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(12);
|
||||
font.setWeight(80);
|
||||
font.setWeight(QFont::Medium);
|
||||
|
||||
QFontMetrics fm(font);
|
||||
|
||||
|
@ -225,7 +223,7 @@ AudioItem::paintEvent(QPaintEvent *event)
|
|||
painter.drawText(QPoint(textStartX, textStartY), elidedText);
|
||||
|
||||
// Draw the filesize.
|
||||
font.setWeight(50);
|
||||
font.setWeight(QFont::Normal);
|
||||
painter.setFont(font);
|
||||
painter.setPen(QPen(textColor_));
|
||||
painter.drawText(QPoint(textStartX, textStartY + 1.5 * fm.ascent()), readableFileSize_);
|
||||
|
|
|
@ -150,8 +150,7 @@ void
|
|||
FileItem::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QFont font;
|
||||
font.setPixelSize(12);
|
||||
font.setWeight(80);
|
||||
font.setWeight(QFont::Medium);
|
||||
|
||||
QFontMetrics fm(font);
|
||||
const int computedWidth = std::min(
|
||||
|
@ -171,8 +170,7 @@ FileItem::paintEvent(QPaintEvent *event)
|
|||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(12);
|
||||
font.setWeight(80);
|
||||
font.setWeight(QFont::Medium);
|
||||
|
||||
QFontMetrics fm(font);
|
||||
|
||||
|
@ -210,7 +208,7 @@ FileItem::paintEvent(QPaintEvent *event)
|
|||
painter.drawText(QPoint(textStartX, textStartY), elidedText);
|
||||
|
||||
// Draw the filesize.
|
||||
font.setWeight(50);
|
||||
font.setWeight(QFont::Normal);
|
||||
painter.setFont(font);
|
||||
painter.setPen(QPen(textColor_));
|
||||
painter.drawText(QPoint(textStartX, textStartY + 1.5 * fm.ascent()), readableFileSize_);
|
||||
|
|
|
@ -183,8 +183,7 @@ ImageItem::paintEvent(QPaintEvent *event)
|
|||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QFont font("Open Sans");
|
||||
font.setPixelSize(conf::fontSize);
|
||||
QFont font;
|
||||
|
||||
QFontMetrics metrics(font);
|
||||
const int fontHeight = metrics.height() + metrics.ascent();
|
||||
|
@ -223,9 +222,9 @@ ImageItem::paintEvent(QPaintEvent *event)
|
|||
|
||||
QString elidedText = metrics.elidedText(text_, Qt::ElideRight, width_ - 10);
|
||||
|
||||
font.setWeight(80);
|
||||
font.setWeight(QFont::Medium);
|
||||
painter.setFont(font);
|
||||
painter.setPen(QPen(QColor("white")));
|
||||
painter.setPen(QPen(QColor(Qt::white)));
|
||||
|
||||
textRegion_.adjust(5, 0, 5, 0);
|
||||
painter.drawText(textRegion_, Qt::AlignVCenter, elidedText);
|
||||
|
|
|
@ -50,7 +50,6 @@ VideoItem::VideoItem(const mtx::events::RoomEvent<mtx::events::msg::Video> &even
|
|||
label_->setMargin(0);
|
||||
label_->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextBrowserInteraction);
|
||||
label_->setOpenExternalLinks(true);
|
||||
label_->setStyleSheet(QString("font-size: %1px;").arg(conf::fontSize));
|
||||
|
||||
layout->addWidget(label_);
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ FlatButton::setFontSize(qreal size)
|
|||
font_size_ = size;
|
||||
|
||||
QFont f(font());
|
||||
f.setPixelSize(size);
|
||||
f.setPointSizeF(size);
|
||||
setFont(f);
|
||||
|
||||
update();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "InfoMessage.h"
|
||||
#include "Config.h"
|
||||
#include "InfoMessage.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QPainter>
|
||||
|
@ -12,18 +12,16 @@ constexpr int HMargin = 20;
|
|||
InfoMessage::InfoMessage(QWidget *parent)
|
||||
: QWidget{parent}
|
||||
{
|
||||
font_.setWeight(60);
|
||||
font_.setPixelSize(conf::timeline::fonts::dateSeparator);
|
||||
initFont();
|
||||
}
|
||||
|
||||
InfoMessage::InfoMessage(QString msg, QWidget *parent)
|
||||
: QWidget{parent}
|
||||
, msg_{msg}
|
||||
{
|
||||
font_.setWeight(60);
|
||||
font_.setPixelSize(conf::timeline::fonts::dateSeparator);
|
||||
initFont();
|
||||
|
||||
QFontMetrics fm{font_};
|
||||
QFontMetrics fm{font()};
|
||||
width_ = fm.width(msg_) + HPadding * 2;
|
||||
height_ = fm.ascent() + 2 * VPadding;
|
||||
|
||||
|
@ -35,7 +33,7 @@ InfoMessage::paintEvent(QPaintEvent *)
|
|||
{
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
p.setFont(font_);
|
||||
p.setFont(font());
|
||||
|
||||
// Center the box horizontally & vertically.
|
||||
auto textRegion = QRectF(width() / 2 - width_ / 2, HMargin, width_, height_);
|
||||
|
@ -54,8 +52,7 @@ InfoMessage::paintEvent(QPaintEvent *)
|
|||
DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent)
|
||||
: InfoMessage{parent}
|
||||
{
|
||||
auto now = QDateTime::currentDateTime();
|
||||
auto days = now.daysTo(datetime);
|
||||
auto now = QDateTime::currentDateTime();
|
||||
|
||||
QString fmt;
|
||||
|
||||
|
@ -64,14 +61,9 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent)
|
|||
else
|
||||
fmt = QString("ddd d MMMM");
|
||||
|
||||
if (days == 0)
|
||||
msg_ = tr("Today");
|
||||
else if (std::abs(days) == 1)
|
||||
msg_ = tr("Yesterday");
|
||||
else
|
||||
msg_ = datetime.toString(fmt);
|
||||
msg_ = datetime.toString(fmt);
|
||||
|
||||
QFontMetrics fm{font_};
|
||||
QFontMetrics fm{font()};
|
||||
width_ = fm.width(msg_) + HPadding * 2;
|
||||
height_ = fm.ascent() + 2 * VPadding;
|
||||
|
||||
|
|
|
@ -25,12 +25,17 @@ public:
|
|||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void initFont()
|
||||
{
|
||||
QFont f;
|
||||
f.setWeight(QFont::Medium);
|
||||
setFont(f);
|
||||
}
|
||||
|
||||
int width_;
|
||||
int height_;
|
||||
|
||||
QString msg_;
|
||||
QFont font_;
|
||||
|
||||
QDateTime datetime_;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ TextField::setLabelFontSize(qreal size)
|
|||
|
||||
if (label_) {
|
||||
QFont font(label_->font());
|
||||
font.setPixelSize(size);
|
||||
font.setPointSizeF(size);
|
||||
label_->setFont(font);
|
||||
label_->update();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue