chore: remove Singleton & replace getIApp with getApp (#5514)
This commit is contained in:
@@ -242,7 +242,7 @@ Split::Split(QWidget *parent)
|
||||
|
||||
// update placeholder text on Twitch account change and channel change
|
||||
this->bSignals_.emplace_back(
|
||||
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
|
||||
getApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
|
||||
this->updateInputPlaceholder();
|
||||
}));
|
||||
this->signalHolder_.managedConnect(channelChanged, [this] {
|
||||
@@ -272,7 +272,7 @@ Split::Split(QWidget *parent)
|
||||
std::ignore = this->view_->openChannelIn.connect(
|
||||
[this](QString twitchChannel, FromTwitchLinkOpenChannelIn openIn) {
|
||||
ChannelPtr channel =
|
||||
getIApp()->getTwitchAbstract()->getOrAddChannel(twitchChannel);
|
||||
getApp()->getTwitchAbstract()->getOrAddChannel(twitchChannel);
|
||||
switch (openIn)
|
||||
{
|
||||
case FromTwitchLinkOpenChannelIn::Split:
|
||||
@@ -387,7 +387,7 @@ Split::Split(QWidget *parent)
|
||||
}
|
||||
|
||||
auto channel = this->getChannel();
|
||||
auto *imageUploader = getIApp()->getImageUploader();
|
||||
auto *imageUploader = getApp()->getImageUploader();
|
||||
|
||||
auto [images, imageProcessError] =
|
||||
imageUploader->getImages(original);
|
||||
@@ -452,7 +452,7 @@ Split::Split(QWidget *parent)
|
||||
},
|
||||
this->signalHolder_);
|
||||
this->addShortcuts();
|
||||
this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
|
||||
this->signalHolder_.managedConnect(getApp()->getHotkeys()->onItemsUpdated,
|
||||
[this]() {
|
||||
this->clearShortcuts();
|
||||
this->addShortcuts();
|
||||
@@ -708,14 +708,14 @@ void Split::addShortcuts()
|
||||
QString requestedText = arguments.at(0).replace('\n', ' ');
|
||||
|
||||
QString inputText = this->getInput().getInputText();
|
||||
QString message = getIApp()->getCommands()->execCustomCommand(
|
||||
QString message = getApp()->getCommands()->execCustomCommand(
|
||||
requestedText.split(' '), Command{"(hotkey)", requestedText},
|
||||
true, this->getChannel(), nullptr,
|
||||
{
|
||||
{"input.text", inputText},
|
||||
});
|
||||
|
||||
message = getIApp()->getCommands()->execCommand(
|
||||
message = getApp()->getCommands()->execCommand(
|
||||
message, this->getChannel(), false);
|
||||
this->getChannel()->sendMessage(message);
|
||||
return "";
|
||||
@@ -750,24 +750,24 @@ void Split::addShortcuts()
|
||||
|
||||
if (mode == 0)
|
||||
{
|
||||
getIApp()->getNotifications()->removeChannelNotification(
|
||||
getApp()->getNotifications()->removeChannelNotification(
|
||||
this->getChannel()->getName(), Platform::Twitch);
|
||||
}
|
||||
else if (mode == 1)
|
||||
{
|
||||
getIApp()->getNotifications()->addChannelNotification(
|
||||
getApp()->getNotifications()->addChannelNotification(
|
||||
this->getChannel()->getName(), Platform::Twitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
getIApp()->getNotifications()->updateChannelNotification(
|
||||
getApp()->getNotifications()->updateChannelNotification(
|
||||
this->getChannel()->getName(), Platform::Twitch);
|
||||
}
|
||||
return "";
|
||||
}},
|
||||
};
|
||||
|
||||
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
|
||||
this->shortcuts_ = getApp()->getHotkeys()->shortcutsForCategory(
|
||||
HotkeyCategory::Split, actions, this);
|
||||
}
|
||||
|
||||
@@ -796,7 +796,7 @@ void Split::updateInputPlaceholder()
|
||||
return;
|
||||
}
|
||||
|
||||
auto user = getIApp()->getAccounts()->twitch.getCurrent();
|
||||
auto user = getApp()->getAccounts()->twitch.getCurrent();
|
||||
QString placeholderText;
|
||||
|
||||
if (user->isAnon())
|
||||
@@ -806,7 +806,7 @@ void Split::updateInputPlaceholder()
|
||||
else
|
||||
{
|
||||
placeholderText = QString("Send message as %1...")
|
||||
.arg(getIApp()
|
||||
.arg(getApp()
|
||||
->getAccounts()
|
||||
->twitch.getCurrent()
|
||||
->getUserName());
|
||||
@@ -817,7 +817,7 @@ void Split::updateInputPlaceholder()
|
||||
|
||||
void Split::joinChannelInNewTab(ChannelPtr channel)
|
||||
{
|
||||
auto &nb = getIApp()->getWindows()->getMainWindow().getNotebook();
|
||||
auto &nb = getApp()->getWindows()->getMainWindow().getNotebook();
|
||||
SplitContainer *container = nb.addPage(true);
|
||||
|
||||
Split *split = new Split(container);
|
||||
@@ -907,7 +907,7 @@ void Split::setChannel(IndirectChannel newChannel)
|
||||
this->actionRequested.invoke(Action::RefreshTab);
|
||||
|
||||
// Queue up save because: Split channel changed
|
||||
getIApp()->getWindows()->queueSave();
|
||||
getApp()->getWindows()->queueSave();
|
||||
}
|
||||
|
||||
void Split::setModerationMode(bool value)
|
||||
@@ -1001,7 +1001,7 @@ void Split::keyReleaseEvent(QKeyEvent *event)
|
||||
void Split::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
// Queue up save because: Split resized
|
||||
getIApp()->getWindows()->queueSave();
|
||||
getApp()->getWindows()->queueSave();
|
||||
|
||||
BaseWidget::resizeEvent(event);
|
||||
|
||||
@@ -1122,8 +1122,7 @@ void Split::openInBrowser()
|
||||
|
||||
void Split::openWhispersInBrowser()
|
||||
{
|
||||
auto userName =
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
auto userName = getApp()->getAccounts()->twitch.getCurrent()->getUserName();
|
||||
QDesktopServices::openUrl("https://twitch.tv/popout/moderator/" + userName +
|
||||
"/whispers");
|
||||
}
|
||||
@@ -1211,7 +1210,7 @@ void Split::showChatterList()
|
||||
auto *item = new QListWidgetItem();
|
||||
item->setText(text);
|
||||
item->setFont(
|
||||
getIApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.0));
|
||||
getApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.0));
|
||||
return item;
|
||||
};
|
||||
|
||||
@@ -1261,7 +1260,7 @@ void Split::showChatterList()
|
||||
auto loadChatters = [=](auto modList, auto vipList, bool isBroadcaster) {
|
||||
getHelix()->getChatters(
|
||||
twitchChannel->roomId(),
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(), 50000,
|
||||
getApp()->getAccounts()->twitch.getCurrent()->getUserId(), 50000,
|
||||
[=](auto chatters) {
|
||||
auto broadcaster = channel->getName().toLower();
|
||||
QStringList chatterList;
|
||||
@@ -1426,8 +1425,8 @@ void Split::showChatterList()
|
||||
}},
|
||||
};
|
||||
|
||||
getIApp()->getHotkeys()->shortcutsForCategory(HotkeyCategory::PopupWindow,
|
||||
actions, chatterDock);
|
||||
getApp()->getHotkeys()->shortcutsForCategory(HotkeyCategory::PopupWindow,
|
||||
actions, chatterDock);
|
||||
|
||||
dockVbox->addWidget(searchBar);
|
||||
dockVbox->addWidget(loadingLabel);
|
||||
@@ -1490,7 +1489,7 @@ void Split::showSearch(bool singleChannel)
|
||||
}
|
||||
|
||||
// Pass every ChannelView for every Split across the app to the search popup
|
||||
auto ¬ebook = getIApp()->getWindows()->getMainWindow().getNotebook();
|
||||
auto ¬ebook = getApp()->getWindows()->getMainWindow().getNotebook();
|
||||
for (int i = 0; i < notebook.getPageCount(); ++i)
|
||||
{
|
||||
auto *container = dynamic_cast<SplitContainer *>(notebook.getPageAt(i));
|
||||
@@ -1509,7 +1508,7 @@ void Split::showSearch(bool singleChannel)
|
||||
void Split::reloadChannelAndSubscriberEmotes()
|
||||
{
|
||||
auto channel = this->getChannel();
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->loadEmotes(channel);
|
||||
getApp()->getAccounts()->twitch.getCurrent()->loadEmotes(channel);
|
||||
|
||||
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ Split *SplitContainer::appendNewSplit(bool openChannelNameDialog)
|
||||
void SplitContainer::insertSplit(Split *split, InsertOptions &&options)
|
||||
{
|
||||
// Queue up save because: Split added
|
||||
getIApp()->getWindows()->queueSave();
|
||||
getApp()->getWindows()->queueSave();
|
||||
|
||||
assertInGuiThread();
|
||||
|
||||
@@ -348,7 +348,7 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split)
|
||||
SplitContainer::Position SplitContainer::deleteSplit(Split *split)
|
||||
{
|
||||
// Queue up save because: Split removed
|
||||
getIApp()->getWindows()->queueSave();
|
||||
getApp()->getWindows()->queueSave();
|
||||
|
||||
assertInGuiThread();
|
||||
assert(split != nullptr);
|
||||
@@ -617,8 +617,8 @@ void SplitContainer::paintEvent(QPaintEvent * /*event*/)
|
||||
|
||||
painter.setPen(this->theme->splits.header.text);
|
||||
|
||||
const auto font = getIApp()->getFonts()->getFont(FontStyle::ChatMedium,
|
||||
this->scale());
|
||||
const auto font =
|
||||
getApp()->getFonts()->getFont(FontStyle::ChatMedium, this->scale());
|
||||
painter.setFont(font);
|
||||
|
||||
QString text = "Click to add a split";
|
||||
@@ -637,7 +637,7 @@ void SplitContainer::paintEvent(QPaintEvent * /*event*/)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getIApp()->getThemes()->isLightTheme())
|
||||
if (getApp()->getThemes()->isLightTheme())
|
||||
{
|
||||
painter.fillRect(rect(), QColor("#999"));
|
||||
}
|
||||
@@ -649,8 +649,8 @@ void SplitContainer::paintEvent(QPaintEvent * /*event*/)
|
||||
|
||||
for (DropRect &dropRect : this->dropRects_)
|
||||
{
|
||||
QColor border = getIApp()->getThemes()->splits.dropTargetRectBorder;
|
||||
QColor background = getIApp()->getThemes()->splits.dropTargetRect;
|
||||
QColor border = getApp()->getThemes()->splits.dropTargetRectBorder;
|
||||
QColor background = getApp()->getThemes()->splits.dropTargetRect;
|
||||
|
||||
if (!dropRect.rect.contains(this->mouseOverPoint_))
|
||||
{
|
||||
@@ -782,7 +782,7 @@ void SplitContainer::applyFromDescriptor(const NodeDescriptor &rootNode)
|
||||
|
||||
void SplitContainer::popup()
|
||||
{
|
||||
Window &window = getIApp()->getWindows()->createWindow(WindowType::Popup);
|
||||
Window &window = getApp()->getWindows()->createWindow(WindowType::Popup);
|
||||
auto *popupContainer = window.getNotebook().getOrAddSelectedPage();
|
||||
|
||||
QJsonObject encodedTab;
|
||||
@@ -1494,15 +1494,15 @@ void SplitContainer::DropOverlay::paintEvent(QPaintEvent * /*event*/)
|
||||
{
|
||||
if (!foundMover && rect.rect.contains(this->mouseOverPoint_))
|
||||
{
|
||||
painter.setBrush(getIApp()->getThemes()->splits.dropPreview);
|
||||
painter.setPen(getIApp()->getThemes()->splits.dropPreviewBorder);
|
||||
painter.setBrush(getApp()->getThemes()->splits.dropPreview);
|
||||
painter.setPen(getApp()->getThemes()->splits.dropPreviewBorder);
|
||||
foundMover = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.setBrush(QColor(0, 0, 0, 0));
|
||||
painter.setPen(QColor(0, 0, 0, 0));
|
||||
// painter.setPen(getIApp()->getThemes()->splits.dropPreviewBorder);
|
||||
// painter.setPen(getApp()->getThemes()->splits.dropPreviewBorder);
|
||||
}
|
||||
|
||||
painter.drawRect(rect.rect);
|
||||
@@ -1584,10 +1584,10 @@ SplitContainer::ResizeHandle::ResizeHandle(SplitContainer *_parent)
|
||||
void SplitContainer::ResizeHandle::paintEvent(QPaintEvent * /*event*/)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setPen(QPen(getIApp()->getThemes()->splits.resizeHandle, 2));
|
||||
painter.setPen(QPen(getApp()->getThemes()->splits.resizeHandle, 2));
|
||||
|
||||
painter.fillRect(this->rect(),
|
||||
getIApp()->getThemes()->splits.resizeHandleBackground);
|
||||
getApp()->getThemes()->splits.resizeHandleBackground);
|
||||
|
||||
if (this->vertical_)
|
||||
{
|
||||
|
||||
@@ -140,7 +140,7 @@ auto formatTooltip(const TwitchChannel::StreamStatus &s, QString thumbnail)
|
||||
}();
|
||||
|
||||
auto extraStreamData = [&s]() -> QString {
|
||||
if (getIApp()->getStreamerMode()->isEnabled() &&
|
||||
if (getApp()->getStreamerMode()->isEnabled() &&
|
||||
getSettings()->streamerModeHideViewerCountAndDuration)
|
||||
{
|
||||
return QStringLiteral(
|
||||
@@ -246,7 +246,7 @@ SplitHeader::SplitHeader(Split *split)
|
||||
});
|
||||
|
||||
this->bSignals_.emplace_back(
|
||||
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
|
||||
getApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
|
||||
this->updateIcons();
|
||||
}));
|
||||
|
||||
@@ -311,7 +311,7 @@ void SplitHeader::initializeLayout()
|
||||
case Qt::LeftButton:
|
||||
if (getSettings()->moderationActions.empty())
|
||||
{
|
||||
getIApp()->getWindows()->showSettingsDialog(
|
||||
getApp()->getWindows()->showSettingsDialog(
|
||||
this, SettingsDialogPreference::
|
||||
ModerationActions);
|
||||
this->split_->setModerationMode(true);
|
||||
@@ -329,7 +329,7 @@ void SplitHeader::initializeLayout()
|
||||
|
||||
case Qt::RightButton:
|
||||
case Qt::MiddleButton:
|
||||
getIApp()->getWindows()->showSettingsDialog(
|
||||
getApp()->getWindows()->showSettingsDialog(
|
||||
this,
|
||||
SettingsDialogPreference::ModerationActions);
|
||||
break;
|
||||
@@ -379,7 +379,7 @@ void SplitHeader::initializeLayout()
|
||||
std::unique_ptr<QMenu> SplitHeader::createMainMenu()
|
||||
{
|
||||
// top level menu
|
||||
const auto &h = getIApp()->getHotkeys();
|
||||
const auto &h = getApp()->getHotkeys();
|
||||
auto menu = std::make_unique<QMenu>();
|
||||
menu->addAction(
|
||||
"Change channel", this->split_, &Split::changeChannel,
|
||||
@@ -552,11 +552,11 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
|
||||
action->setShortcut(notifySeq);
|
||||
|
||||
QObject::connect(moreMenu, &QMenu::aboutToShow, this, [action, this]() {
|
||||
action->setChecked(getIApp()->getNotifications()->isChannelNotified(
|
||||
action->setChecked(getApp()->getNotifications()->isChannelNotified(
|
||||
this->split_->getChannel()->getName(), Platform::Twitch));
|
||||
});
|
||||
QObject::connect(action, &QAction::triggered, this, [this]() {
|
||||
getIApp()->getNotifications()->updateChannelNotification(
|
||||
getApp()->getNotifications()->updateChannelNotification(
|
||||
this->split_->getChannel()->getName(), Platform::Twitch);
|
||||
});
|
||||
|
||||
@@ -1078,7 +1078,7 @@ void SplitHeader::reloadSubscriberEmotes()
|
||||
this->lastReloadedSubEmotes_ = now;
|
||||
|
||||
auto channel = this->split_->getChannel();
|
||||
getIApp()->getAccounts()->twitch.getCurrent()->loadEmotes(channel);
|
||||
getApp()->getAccounts()->twitch.getCurrent()->loadEmotes(channel);
|
||||
}
|
||||
|
||||
void SplitHeader::reconnect()
|
||||
|
||||
@@ -68,7 +68,7 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
|
||||
this->hideCompletionPopup();
|
||||
});
|
||||
this->scaleChangedEvent(this->scale());
|
||||
this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
|
||||
this->signalHolder_.managedConnect(getApp()->getHotkeys()->onItemsUpdated,
|
||||
[this]() {
|
||||
this->clearShortcuts();
|
||||
this->addShortcuts();
|
||||
@@ -77,7 +77,7 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
|
||||
|
||||
void SplitInput::initLayout()
|
||||
{
|
||||
auto *app = getIApp();
|
||||
auto *app = getApp();
|
||||
LayoutCreator<SplitInput> layoutCreator(this);
|
||||
|
||||
auto layout =
|
||||
@@ -219,7 +219,7 @@ void SplitInput::initLayout()
|
||||
|
||||
void SplitInput::scaleChangedEvent(float scale)
|
||||
{
|
||||
auto *app = getIApp();
|
||||
auto *app = getApp();
|
||||
// update the icon size of the buttons
|
||||
this->updateEmoteButton();
|
||||
this->updateCancelReplyButton();
|
||||
@@ -352,7 +352,7 @@ QString SplitInput::handleSendMessage(const std::vector<QString> &arguments)
|
||||
|
||||
message = message.replace('\n', ' ');
|
||||
QString sendMessage =
|
||||
getIApp()->getCommands()->execCommand(message, c, false);
|
||||
getApp()->getCommands()->execCommand(message, c, false);
|
||||
|
||||
c->sendMessage(sendMessage);
|
||||
|
||||
@@ -388,7 +388,7 @@ QString SplitInput::handleSendMessage(const std::vector<QString> &arguments)
|
||||
|
||||
message = message.replace('\n', ' ');
|
||||
QString sendMessage =
|
||||
getIApp()->getCommands()->execCommand(message, c, false);
|
||||
getApp()->getCommands()->execCommand(message, c, false);
|
||||
|
||||
// Reply within TwitchChannel
|
||||
tc->sendReply(sendMessage, this->replyTarget_->id);
|
||||
@@ -413,7 +413,7 @@ QString SplitInput::handleSendMessage(const std::vector<QString> &arguments)
|
||||
|
||||
message = message.replace('\n', ' ');
|
||||
QString sendMessage =
|
||||
getIApp()->getCommands()->execCommand(message, c, false);
|
||||
getApp()->getCommands()->execCommand(message, c, false);
|
||||
|
||||
// Reply within TwitchChannel
|
||||
tc->sendReply(sendMessage, this->replyTarget_->id);
|
||||
@@ -698,7 +698,7 @@ void SplitInput::addShortcuts()
|
||||
}},
|
||||
};
|
||||
|
||||
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
|
||||
this->shortcuts_ = getApp()->getHotkeys()->shortcutsForCategory(
|
||||
HotkeyCategory::SplitInput, actions, this->parentWidget());
|
||||
}
|
||||
|
||||
@@ -983,7 +983,7 @@ void SplitInput::setInputText(const QString &newInputText)
|
||||
|
||||
void SplitInput::editTextChanged()
|
||||
{
|
||||
auto *app = getIApp();
|
||||
auto *app = getApp();
|
||||
|
||||
// set textLengthLabel value
|
||||
QString text = this->ui_.textEdit->toPlainText();
|
||||
|
||||
@@ -268,8 +268,8 @@ void SplitOverlay::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
rect.setRight(rect.right() - 1);
|
||||
rect.setBottom(rect.bottom() - 1);
|
||||
painter.setPen(getIApp()->getThemes()->splits.dropPreviewBorder);
|
||||
painter.setBrush(getIApp()->getThemes()->splits.dropPreview);
|
||||
painter.setPen(getApp()->getThemes()->splits.dropPreviewBorder);
|
||||
painter.setBrush(getApp()->getThemes()->splits.dropPreview);
|
||||
painter.drawRect(rect);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user