refactor: Remove most raw accesses into Application (#5104)
This commit is contained in:
@@ -252,7 +252,7 @@ namespace detail {
|
||||
}
|
||||
}
|
||||
|
||||
getApp()->windows->forceLayoutChannelViews();
|
||||
getIApp()->getWindows()->forceLayoutChannelViews();
|
||||
|
||||
loadedEventQueued = false;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &username,
|
||||
MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
|
||||
: MessageBuilder()
|
||||
{
|
||||
auto current = getApp()->accounts->twitch.getCurrent();
|
||||
auto current = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
|
||||
this->emplace<TimestampElement>();
|
||||
this->message().flags.set(MessageFlag::System);
|
||||
@@ -682,7 +682,8 @@ void MessageBuilder::addIrcMessageText(const QString &text)
|
||||
|
||||
auto words = text.split(' ');
|
||||
MessageColor defaultColorType = MessageColor::Text;
|
||||
const auto &defaultColor = defaultColorType.getColor(*getApp()->themes);
|
||||
const auto &defaultColor =
|
||||
defaultColorType.getColor(*getIApp()->getThemes());
|
||||
QColor textColor = defaultColor;
|
||||
int fg = -1;
|
||||
int bg = -1;
|
||||
@@ -726,7 +727,7 @@ void MessageBuilder::addIrcMessageText(const QString &text)
|
||||
if (fg >= 0 && fg <= 98)
|
||||
{
|
||||
textColor = IRC_COLORS[fg];
|
||||
getApp()->themes->normalizeColor(textColor);
|
||||
getIApp()->getThemes()->normalizeColor(textColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -766,7 +767,7 @@ void MessageBuilder::addIrcMessageText(const QString &text)
|
||||
if (fg >= 0 && fg <= 98)
|
||||
{
|
||||
textColor = IRC_COLORS[fg];
|
||||
getApp()->themes->normalizeColor(textColor);
|
||||
getIApp()->getThemes()->normalizeColor(textColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -522,14 +522,14 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
|
||||
if (flags.hasAny(this->getFlags()))
|
||||
{
|
||||
QFontMetrics metrics =
|
||||
app->fonts->getFontMetrics(this->style_, container.getScale());
|
||||
app->getFonts()->getFontMetrics(this->style_, container.getScale());
|
||||
|
||||
for (Word &word : this->words_)
|
||||
{
|
||||
auto getTextLayoutElement = [&](QString text, int width,
|
||||
bool hasTrailingSpace) {
|
||||
auto color = this->color_.getColor(*app->themes);
|
||||
app->themes->normalizeColor(color);
|
||||
auto color = this->color_.getColor(*app->getThemes());
|
||||
app->getThemes()->normalizeColor(color);
|
||||
|
||||
auto *e = (new TextLayoutElement(
|
||||
*this, text, QSize(width, metrics.height()),
|
||||
@@ -642,12 +642,12 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
||||
if (flags.hasAny(this->getFlags()))
|
||||
{
|
||||
QFontMetrics metrics =
|
||||
app->fonts->getFontMetrics(this->style_, container.getScale());
|
||||
app->getFonts()->getFontMetrics(this->style_, container.getScale());
|
||||
|
||||
auto getTextLayoutElement = [&](QString text, int width,
|
||||
bool hasTrailingSpace) {
|
||||
auto color = this->color_.getColor(*app->themes);
|
||||
app->themes->normalizeColor(color);
|
||||
auto color = this->color_.getColor(*app->getThemes());
|
||||
app->getThemes()->normalizeColor(color);
|
||||
|
||||
auto *e = (new TextLayoutElement(
|
||||
*this, text, QSize(width, metrics.height()), color,
|
||||
|
||||
@@ -236,7 +236,7 @@ void SharedMessageBuilder::triggerHighlights(
|
||||
|
||||
if (windowAlert)
|
||||
{
|
||||
getApp()->windows->sendAlert();
|
||||
getIApp()->getWindows()->sendAlert();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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