chore: remove Singleton & replace getIApp with getApp (#5514)

This commit is contained in:
pajlada
2024-07-21 15:09:59 +02:00
committed by GitHub
parent 21186df058
commit 5deec1f02f
145 changed files with 802 additions and 856 deletions
+3 -3
View File
@@ -50,7 +50,7 @@ Frames::Frames(QList<Frame> &&frames)
DebugCount::increase("animated images");
this->gifTimerConnection_ =
getIApp()->getEmotes()->getGIFTimer().signal.connect([this] {
getApp()->getEmotes()->getGIFTimer().signal.connect([this] {
this->advance();
});
}
@@ -67,7 +67,7 @@ Frames::Frames(QList<Frame> &&frames)
else
{
this->durationOffset_ = std::min<int>(
int(getIApp()->getEmotes()->getGIFTimer().position() % totalLength),
int(getApp()->getEmotes()->getGIFTimer().position() % totalLength),
60000);
}
this->processOffset();
@@ -242,7 +242,7 @@ void assignFrames(std::weak_ptr<Image> weak, QList<Frame> parsed)
isPushQueued = true;
postToThread([] {
isPushQueued = false;
getIApp()->getWindows()->forceLayoutChannelViews();
getApp()->getWindows()->forceLayoutChannelViews();
});
}
};
+6 -6
View File
@@ -203,7 +203,7 @@ MessageBuilder::MessageBuilder(TimeoutMessageTag, const QString &username,
MessageBuilder::MessageBuilder(const BanAction &action, uint32_t count)
: MessageBuilder()
{
auto current = getIApp()->getAccounts()->twitch.getCurrent();
auto current = getApp()->getAccounts()->twitch.getCurrent();
this->emplace<TimestampElement>();
this->message().flags.set(MessageFlag::System);
@@ -676,7 +676,7 @@ void MessageBuilder::addLink(const linkparser::Parsed &parsedLink,
MessageElementFlag::Text, this->textColor_);
}
getIApp()->getLinkResolver()->resolve(el->linkInfo());
getApp()->getLinkResolver()->resolve(el->linkInfo());
}
void MessageBuilder::addIrcMessageText(const QString &text)
@@ -686,7 +686,7 @@ void MessageBuilder::addIrcMessageText(const QString &text)
auto words = text.split(' ');
MessageColor defaultColorType = MessageColor::Text;
const auto &defaultColor =
defaultColorType.getColor(*getIApp()->getThemes());
defaultColorType.getColor(*getApp()->getThemes());
QColor textColor = defaultColor;
int fg = -1;
int bg = -1;
@@ -728,7 +728,7 @@ void MessageBuilder::addIrcMessageText(const QString &text)
if (fg >= 0 && fg <= 98)
{
textColor = IRC_COLORS[fg];
getIApp()->getThemes()->normalizeColor(textColor);
getApp()->getThemes()->normalizeColor(textColor);
}
else
{
@@ -768,7 +768,7 @@ void MessageBuilder::addIrcMessageText(const QString &text)
if (fg >= 0 && fg <= 98)
{
textColor = IRC_COLORS[fg];
getIApp()->getThemes()->normalizeColor(textColor);
getApp()->getThemes()->normalizeColor(textColor);
}
else
{
@@ -810,7 +810,7 @@ void MessageBuilder::addIrcWord(const QString &text, const QColor &color,
bool addSpace)
{
this->textColor_ = color;
for (auto &variant : getIApp()->getEmotes()->getEmojis()->parse(text))
for (auto &variant : getApp()->getEmotes()->getEmojis()->parse(text))
{
boost::apply_visitor(
[&](auto &&arg) {
+2 -2
View File
@@ -454,7 +454,7 @@ TextElement::TextElement(const QString &text, MessageElementFlags flags,
void TextElement::addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags)
{
auto *app = getIApp();
auto *app = getApp();
if (flags.hasAny(this->getFlags()))
{
@@ -566,7 +566,7 @@ SingleLineTextElement::SingleLineTextElement(const QString &text,
void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags)
{
auto *app = getIApp();
auto *app = getApp();
if (flags.hasAny(this->getFlags()))
{
+4 -4
View File
@@ -156,7 +156,7 @@ void SharedMessageBuilder::parseHighlights()
}
auto badges = SharedMessageBuilder::parseBadgeTag(this->tags);
auto [highlighted, highlightResult] = getIApp()->getHighlights()->check(
auto [highlighted, highlightResult] = getApp()->getHighlights()->check(
this->args, badges, this->message().loginName, this->originalMessage_,
this->message().flags);
@@ -203,7 +203,7 @@ void SharedMessageBuilder::triggerHighlights(
const QString &channelName, bool playSound,
const std::optional<QUrl> &customSoundUrl, bool windowAlert)
{
if (getIApp()->getStreamerMode()->isEnabled() &&
if (getApp()->getStreamerMode()->isEnabled() &&
getSettings()->streamerModeMuteMentions)
{
// We are in streamer mode with muting mention sounds enabled. Do nothing.
@@ -232,12 +232,12 @@ void SharedMessageBuilder::triggerHighlights(
{
soundUrl = getFallbackHighlightSound();
}
getIApp()->getSound()->play(soundUrl);
getApp()->getSound()->play(soundUrl);
}
if (windowAlert)
{
getIApp()->getWindows()->sendAlert();
getApp()->getWindows()->sendAlert();
}
}
+2 -2
View File
@@ -88,7 +88,7 @@ bool MessageLayout::layout(int width, float scale, float imageScale,
this->currentLayoutWidth_ = width;
// check if layout state changed
const auto layoutGeneration = getIApp()->getWindows()->getGeneration();
const auto layoutGeneration = getApp()->getWindows()->getGeneration();
if (this->layoutState_ != layoutGeneration)
{
layoutRequired = true;
@@ -166,7 +166,7 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags flags)
{
if (hideModerationActions ||
(getSettings()->streamerModeHideModActions &&
getIApp()->getStreamerMode()->isEnabled()))
getApp()->getStreamerMode()->isEnabled()))
{
continue;
}
@@ -48,7 +48,7 @@ void MessageLayoutContainer::beginLayout(int width, float scale,
this->imageScale_ = imageScale;
this->flags_ = flags;
auto mediumFontMetrics =
getIApp()->getFonts()->getFontMetrics(FontStyle::ChatMedium, scale);
getApp()->getFonts()->getFontMetrics(FontStyle::ChatMedium, scale);
this->textLineHeight_ = mediumFontMetrics.height();
this->spaceWidth_ = mediumFontMetrics.horizontalAdvance(' ');
this->dotdotdotWidth_ = mediumFontMetrics.horizontalAdvance("...");