refactor: Remove most raw accesses into Application (#5104)
This commit is contained in:
@@ -78,8 +78,6 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
|
||||
{
|
||||
// BenchmarkGuard benchmark("MessageLayout::layout()");
|
||||
|
||||
auto *app = getApp();
|
||||
|
||||
bool layoutRequired = false;
|
||||
|
||||
// check if width changed
|
||||
@@ -88,11 +86,12 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
|
||||
this->currentLayoutWidth_ = width;
|
||||
|
||||
// check if layout state changed
|
||||
if (this->layoutState_ != app->windows->getGeneration())
|
||||
const auto layoutGeneration = getIApp()->getWindows()->getGeneration();
|
||||
if (this->layoutState_ != layoutGeneration)
|
||||
{
|
||||
layoutRequired = true;
|
||||
this->flags.set(MessageLayoutFlag::RequiresBufferUpdate);
|
||||
this->layoutState_ = app->windows->getGeneration();
|
||||
this->layoutState_ = layoutGeneration;
|
||||
}
|
||||
|
||||
// check if work mask changed
|
||||
|
||||
@@ -47,7 +47,7 @@ void MessageLayoutContainer::beginLayout(int width, float scale,
|
||||
this->scale_ = scale;
|
||||
this->flags_ = flags;
|
||||
auto mediumFontMetrics =
|
||||
getApp()->fonts->getFontMetrics(FontStyle::ChatMedium, scale);
|
||||
getIApp()->getFonts()->getFontMetrics(FontStyle::ChatMedium, scale);
|
||||
this->textLineHeight_ = mediumFontMetrics.height();
|
||||
this->spaceWidth_ = mediumFontMetrics.horizontalAdvance(' ');
|
||||
this->dotdotdotWidth_ = mediumFontMetrics.horizontalAdvance("...");
|
||||
|
||||
@@ -442,7 +442,7 @@ void TextLayoutElement::paint(QPainter &painter,
|
||||
|
||||
painter.setPen(this->color_);
|
||||
|
||||
painter.setFont(app->fonts->getFont(this->style_, this->scale_));
|
||||
painter.setFont(app->getFonts()->getFont(this->style_, this->scale_));
|
||||
|
||||
painter.drawText(
|
||||
QRectF(this->getRect().x(), this->getRect().y(), 10000, 10000), text,
|
||||
@@ -463,7 +463,7 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
|
||||
auto *app = getApp();
|
||||
|
||||
auto metrics = app->fonts->getFontMetrics(this->style_, this->scale_);
|
||||
auto metrics = app->getFonts()->getFontMetrics(this->style_, this->scale_);
|
||||
auto x = this->getRect().left();
|
||||
|
||||
for (auto i = 0; i < this->getText().size(); i++)
|
||||
@@ -498,7 +498,7 @@ int TextLayoutElement::getXFromIndex(size_t index)
|
||||
auto *app = getApp();
|
||||
|
||||
QFontMetrics metrics =
|
||||
app->fonts->getFontMetrics(this->style_, this->scale_);
|
||||
app->getFonts()->getFontMetrics(this->style_, this->scale_);
|
||||
|
||||
if (index <= 0)
|
||||
{
|
||||
@@ -546,7 +546,7 @@ void TextIconLayoutElement::paint(QPainter &painter,
|
||||
{
|
||||
auto *app = getApp();
|
||||
|
||||
QFont font = app->fonts->getFont(FontStyle::Tiny, this->scale);
|
||||
QFont font = app->getFonts()->getFont(FontStyle::Tiny, this->scale);
|
||||
|
||||
painter.setPen(messageColors.system);
|
||||
painter.setFont(font);
|
||||
|
||||
Reference in New Issue
Block a user