refactor: Remove most raw accesses into Application (#5104)

This commit is contained in:
pajlada
2024-01-19 17:59:55 +01:00
committed by GitHub
parent 326a402710
commit 4380ef8c5f
82 changed files with 552 additions and 452 deletions
+31 -25
View File
@@ -396,11 +396,11 @@ void ChannelView::initializeScrollbar()
void ChannelView::initializeSignals()
{
this->signalHolder_.managedConnect(getApp()->windows->wordFlagsChanged,
[this] {
this->queueLayout();
this->update();
});
this->signalHolder_.managedConnect(
getIApp()->getWindows()->wordFlagsChanged, [this] {
this->queueLayout();
this->update();
});
getSettings()->showLastMessageIndicator.connect(
[this](auto, auto) {
@@ -409,7 +409,7 @@ void ChannelView::initializeSignals()
this->signalHolder_);
this->signalHolder_.managedConnect(
getApp()->windows->gifRepaintRequested, [&] {
getIApp()->getWindows()->gifRepaintRequested, [&] {
if (!this->animationArea_.isEmpty())
{
this->queueUpdate(this->animationArea_);
@@ -417,7 +417,7 @@ void ChannelView::initializeSignals()
});
this->signalHolder_.managedConnect(
getApp()->windows->layoutRequested, [&](Channel *channel) {
getIApp()->getWindows()->layoutRequested, [&](Channel *channel) {
if (this->isVisible() &&
(channel == nullptr || this->channel_.get() == channel))
{
@@ -425,9 +425,10 @@ void ChannelView::initializeSignals()
}
});
this->signalHolder_.managedConnect(getApp()->fonts->fontChanged, [this] {
this->queueLayout();
});
this->signalHolder_.managedConnect(getIApp()->getFonts()->fontChanged,
[this] {
this->queueLayout();
});
}
bool ChannelView::pausable() const
@@ -1023,8 +1024,11 @@ bool ChannelView::shouldIncludeMessage(const MessagePtr &m) const
if (this->channelFilters_)
{
if (getSettings()->excludeUserMessagesFromFilter &&
getApp()->accounts->twitch.getCurrent()->getUserName().compare(
m->loginName, Qt::CaseInsensitive) == 0)
getIApp()
->getAccounts()
->twitch.getCurrent()
->getUserName()
.compare(m->loginName, Qt::CaseInsensitive) == 0)
{
return true;
}
@@ -1290,7 +1294,7 @@ MessageElementFlags ChannelView::getFlags() const
return *this->overrideFlags_;
}
MessageElementFlags flags = app->windows->getWordFlags();
MessageElementFlags flags = app->getWindows()->getWordFlags();
auto *split = dynamic_cast<Split *>(this->parentWidget());
@@ -1376,7 +1380,7 @@ bool ChannelView::scrollToMessage(const MessagePtr &message)
this->scrollToMessageLayout(messagesSnapshot[messageIdx].get(), messageIdx);
if (this->split_)
{
getApp()->windows->select(this->split_);
getIApp()->getWindows()->select(this->split_);
}
return true;
}
@@ -1408,7 +1412,7 @@ bool ChannelView::scrollToMessageId(const QString &messageId)
this->scrollToMessageLayout(messagesSnapshot[messageIdx].get(), messageIdx);
if (this->split_)
{
getApp()->windows->select(this->split_);
getIApp()->getWindows()->select(this->split_);
}
return true;
}
@@ -2444,7 +2448,7 @@ void ChannelView::addMessageContextMenuItems(QMenu *menu,
}
else if (isMentions || isAutomod)
{
getApp()->windows->scrollToMessage(messagePtr);
getIApp()->getWindows()->scrollToMessage(messagePtr);
}
else if (isReplyOrUserCard)
{
@@ -2454,7 +2458,7 @@ void ChannelView::addMessageContextMenuItems(QMenu *menu,
if (type == Channel::Type::TwitchMentions ||
type == Channel::Type::TwitchAutomod)
{
getApp()->windows->scrollToMessage(messagePtr);
getIApp()->getWindows()->scrollToMessage(messagePtr);
}
else
{
@@ -2535,7 +2539,7 @@ void ChannelView::addCommandExecutionContextMenuItems(
/* Get commands to be displayed in context menu;
* only those that had the showInMsgContextMenu check box marked in the Commands page */
std::vector<Command> cmds;
for (const auto &cmd : getApp()->commands->items)
for (const auto &cmd : getIApp()->getCommands()->items)
{
if (cmd.showInMsgContextMenu)
{
@@ -2582,13 +2586,14 @@ void ChannelView::addCommandExecutionContextMenuItems(
}
// Execute command through right-clicking a message -> Execute command
QString value = getApp()->commands->execCustomCommand(
QString value = getIApp()->getCommands()->execCustomCommand(
inputText.split(' '), cmd, true, channel, layout->getMessage(),
{
{"input.text", userText},
});
value = getApp()->commands->execCommand(value, channel, false);
value =
getIApp()->getCommands()->execCommand(value, channel, false);
channel->sendMessage(value);
});
@@ -2753,24 +2758,25 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
}
// Execute command clicking a moderator button
value = getApp()->commands->execCustomCommand(
value = getIApp()->getCommands()->execCustomCommand(
QStringList(), Command{"(modaction)", value}, true, channel,
layout->getMessage());
value = getApp()->commands->execCommand(value, channel, false);
value =
getIApp()->getCommands()->execCommand(value, channel, false);
channel->sendMessage(value);
}
break;
case Link::AutoModAllow: {
getApp()->accounts->twitch.getCurrent()->autoModAllow(
getIApp()->getAccounts()->twitch.getCurrent()->autoModAllow(
link.value, this->channel());
}
break;
case Link::AutoModDeny: {
getApp()->accounts->twitch.getCurrent()->autoModDeny(
getIApp()->getAccounts()->twitch.getCurrent()->autoModDeny(
link.value, this->channel());
}
break;
@@ -2784,7 +2790,7 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
// Get all currently open pages
QList<SplitContainer *> openPages;
auto &nb = getApp()->windows->getMainWindow().getNotebook();
auto &nb = getIApp()->getWindows()->getMainWindow().getNotebook();
for (int i = 0; i < nb.getPageCount(); ++i)
{
openPages.push_back(
+4 -4
View File
@@ -289,7 +289,7 @@ const QString &NotebookTab::getTitle() const
void NotebookTab::titleUpdated()
{
// Queue up save because: Tab title changed
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
this->notebook_->refresh();
this->updateSize();
this->update();
@@ -429,9 +429,9 @@ void NotebookTab::paintEvent(QPaintEvent *)
auto div = std::max<float>(0.01f, this->logicalDpiX() * deviceDpi(this));
painter.setFont(
getApp()->fonts->getFont(FontStyle::UiTabs, scale * 96.f / div));
getIApp()->getFonts()->getFont(FontStyle::UiTabs, scale * 96.f / div));
QFontMetrics metrics =
app->fonts->getFontMetrics(FontStyle::UiTabs, scale * 96.f / div);
app->getFonts()->getFontMetrics(FontStyle::UiTabs, scale * 96.f / div);
int height = int(scale * NOTEBOOK_TAB_HEIGHT);
@@ -613,7 +613,7 @@ void NotebookTab::paintEvent(QPaintEvent *)
borderRect = QRect(0, 0, this->width(), 1);
break;
}
painter.fillRect(borderRect, app->themes->window.background);
painter.fillRect(borderRect, app->getThemes()->window.background);
}
}
+2 -2
View File
@@ -103,7 +103,7 @@ void SearchPopup::addShortcuts()
{"scrollPage", nullptr},
};
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this);
}
@@ -138,7 +138,7 @@ void SearchPopup::goToMessage(const MessagePtr &message)
if (type == Channel::Type::TwitchMentions ||
type == Channel::Type::TwitchAutomod)
{
getApp()->windows->scrollToMessage(message);
getIApp()->getWindows()->scrollToMessage(message);
return;
}