refactor: Fonts (#5228)
This commit is contained in:
@@ -775,7 +775,8 @@ void BaseWindow::scaleChangedEvent(float scale)
|
||||
this->calcButtonsSizes();
|
||||
#endif
|
||||
|
||||
this->setFont(getFonts()->getFont(FontStyle::UiTabs, this->qtFontScale()));
|
||||
this->setFont(
|
||||
getIApp()->getFonts()->getFont(FontStyle::UiTabs, this->qtFontScale()));
|
||||
}
|
||||
|
||||
void BaseWindow::paintEvent(QPaintEvent *)
|
||||
|
||||
+10
-7
@@ -1,4 +1,6 @@
|
||||
#include "Label.hpp"
|
||||
#include "widgets/Label.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
@@ -14,9 +16,10 @@ Label::Label(BaseWidget *parent, QString text, FontStyle style)
|
||||
, text_(std::move(text))
|
||||
, fontStyle_(style)
|
||||
{
|
||||
this->connections_.managedConnect(getFonts()->fontChanged, [this] {
|
||||
this->updateSize();
|
||||
});
|
||||
this->connections_.managedConnect(getIApp()->getFonts()->fontChanged,
|
||||
[this] {
|
||||
this->updateSize();
|
||||
});
|
||||
}
|
||||
|
||||
const QString &Label::getText() const
|
||||
@@ -92,12 +95,12 @@ void Label::paintEvent(QPaintEvent *)
|
||||
1.0;
|
||||
#endif
|
||||
|
||||
QFontMetrics metrics = getFonts()->getFontMetrics(
|
||||
QFontMetrics metrics = getIApp()->getFonts()->getFontMetrics(
|
||||
this->getFontStyle(),
|
||||
this->scale() * 96.f /
|
||||
std::max<float>(
|
||||
0.01F, static_cast<float>(this->logicalDpiX() * deviceDpi)));
|
||||
painter.setFont(getFonts()->getFont(
|
||||
painter.setFont(getIApp()->getFonts()->getFont(
|
||||
this->getFontStyle(),
|
||||
this->scale() * 96.f /
|
||||
std::max<float>(
|
||||
@@ -128,7 +131,7 @@ void Label::paintEvent(QPaintEvent *)
|
||||
void Label::updateSize()
|
||||
{
|
||||
QFontMetrics metrics =
|
||||
getFonts()->getFontMetrics(this->fontStyle_, this->scale());
|
||||
getIApp()->getFonts()->getFontMetrics(this->fontStyle_, this->scale());
|
||||
|
||||
int width =
|
||||
metrics.horizontalAdvance(this->text_) + (2 * this->getOffset());
|
||||
|
||||
@@ -47,9 +47,10 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||
this->setLayout(this->vLayout_);
|
||||
this->currentStyle_ = TooltipStyle::Vertical;
|
||||
|
||||
this->connections_.managedConnect(getFonts()->fontChanged, [this] {
|
||||
this->updateFont();
|
||||
});
|
||||
this->connections_.managedConnect(getIApp()->getFonts()->fontChanged,
|
||||
[this] {
|
||||
this->updateFont();
|
||||
});
|
||||
this->updateFont();
|
||||
|
||||
auto *windows = getIApp()->getWindows();
|
||||
@@ -299,8 +300,8 @@ void TooltipWidget::scaleChangedEvent(float)
|
||||
|
||||
void TooltipWidget::updateFont()
|
||||
{
|
||||
this->setFont(
|
||||
getFonts()->getFont(FontStyle::ChatMediumSmall, this->scale()));
|
||||
this->setFont(getIApp()->getFonts()->getFont(FontStyle::ChatMediumSmall,
|
||||
this->scale()));
|
||||
}
|
||||
|
||||
void TooltipWidget::setWordWrap(bool wrap)
|
||||
|
||||
@@ -572,7 +572,8 @@ void UserInfoPopup::themeChangedEvent()
|
||||
|
||||
for (auto &&child : this->findChildren<QCheckBox *>())
|
||||
{
|
||||
child->setFont(getFonts()->getFont(FontStyle::UiMedium, this->scale()));
|
||||
child->setFont(
|
||||
getIApp()->getFonts()->getFont(FontStyle::UiMedium, this->scale()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -620,7 +620,7 @@ void ChannelView::scaleChangedEvent(float scale)
|
||||
0.01, this->logicalDpiX() * this->devicePixelRatioF());
|
||||
#endif
|
||||
this->goToBottom_->getLabel().setFont(
|
||||
getFonts()->getFont(FontStyle::UiMedium, factor));
|
||||
getIApp()->getFonts()->getFont(FontStyle::UiMedium, factor));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,8 +166,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||
}
|
||||
|
||||
layout.addDropdown<QString>(
|
||||
"Font", {"Segoe UI", "Arial", "Choose..."},
|
||||
getIApp()->getFonts()->chatFontFamily,
|
||||
"Font", {"Segoe UI", "Arial", "Choose..."}, s.chatFontFamily,
|
||||
[](auto val) {
|
||||
return val;
|
||||
},
|
||||
@@ -177,7 +176,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
||||
true, "", true);
|
||||
layout.addDropdown<int>(
|
||||
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
|
||||
getIApp()->getFonts()->chatFontSize,
|
||||
s.chatFontSize,
|
||||
[](auto val) {
|
||||
return QString::number(val) + "pt";
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user