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
+7 -6
View File
@@ -15,20 +15,21 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
this->addItem(ANONYMOUS_USERNAME_LABEL);
for (const auto &userName : app->accounts->twitch.getUsernames())
for (const auto &userName : app->getAccounts()->twitch.getUsernames())
{
this->addItem(userName);
}
this->managedConnections_.managedConnect(
app->accounts->twitch.userListUpdated, [=, this]() {
app->getAccounts()->twitch.userListUpdated, [=, this]() {
this->blockSignals(true);
this->clear();
this->addItem(ANONYMOUS_USERNAME_LABEL);
for (const auto &userName : app->accounts->twitch.getUsernames())
for (const auto &userName :
app->getAccounts()->twitch.getUsernames())
{
this->addItem(userName);
}
@@ -47,11 +48,11 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
if (newUsername.compare(ANONYMOUS_USERNAME_LABEL,
Qt::CaseInsensitive) == 0)
{
app->accounts->twitch.currentUsername = "";
app->getAccounts()->twitch.currentUsername = "";
}
else
{
app->accounts->twitch.currentUsername = newUsername;
app->getAccounts()->twitch.currentUsername = newUsername;
}
}
});
@@ -71,7 +72,7 @@ void AccountSwitchWidget::refreshSelection()
{
auto *app = getApp();
auto currentUser = app->accounts->twitch.getCurrent();
auto currentUser = app->getAccounts()->twitch.getCurrent();
if (currentUser->isAnon())
{
+2 -2
View File
@@ -508,7 +508,7 @@ void BaseWindow::resizeEvent(QResizeEvent *)
// Queue up save because: Window resized
if (!flags_.has(DisableLayoutSave))
{
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
}
#ifdef USEWINSDK
@@ -540,7 +540,7 @@ void BaseWindow::moveEvent(QMoveEvent *event)
#ifdef CHATTERINO
if (!flags_.has(DisableLayoutSave))
{
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
}
#endif
+16 -15
View File
@@ -70,7 +70,7 @@ Notebook::Notebook(QWidget *parent)
NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select)
{
// Queue up save because: Tab added
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
auto *tab = new NotebookTab(this);
tab->page = page;
@@ -100,7 +100,7 @@ NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select)
void Notebook::removePage(QWidget *page)
{
// Queue up save because: Tab removed
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
int removingIndex = this->indexOf(page);
assert(removingIndex != -1);
@@ -491,7 +491,7 @@ void Notebook::rearrangePage(QWidget *page, int index)
}
// Queue up save because: Tab rearranged
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
this->items_.move(this->indexOf(page), index);
@@ -532,16 +532,16 @@ void Notebook::setShowTabs(bool value)
void Notebook::showTabVisibilityInfoPopup()
{
auto unhideSeq = getApp()->hotkeys->getDisplaySequence(
auto unhideSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "setTabVisibility", {std::vector<QString>()});
if (unhideSeq.isEmpty())
{
unhideSeq = getApp()->hotkeys->getDisplaySequence(
unhideSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "setTabVisibility", {{"toggle"}});
}
if (unhideSeq.isEmpty())
{
unhideSeq = getApp()->hotkeys->getDisplaySequence(
unhideSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "setTabVisibility", {{"on"}});
}
QString hotkeyInfo = "(currently unbound)";
@@ -1293,7 +1293,7 @@ SplitNotebook::SplitNotebook(Window *parent)
this->signalHolder_, true);
this->signalHolder_.managedConnect(
getApp()->windows->selectSplit, [this](Split *split) {
getIApp()->getWindows()->selectSplit, [this](Split *split) {
for (auto &&item : this->items())
{
if (auto *sc = dynamic_cast<SplitContainer *>(item.page))
@@ -1310,13 +1310,14 @@ SplitNotebook::SplitNotebook(Window *parent)
}
});
this->signalHolder_.managedConnect(getApp()->windows->selectSplitContainer,
[this](SplitContainer *sc) {
this->select(sc);
});
this->signalHolder_.managedConnect(
getIApp()->getWindows()->selectSplitContainer,
[this](SplitContainer *sc) {
this->select(sc);
});
this->signalHolder_.managedConnect(
getApp()->windows->scrollToMessageSignal,
getIApp()->getWindows()->scrollToMessageSignal,
[this](const MessagePtr &message) {
for (auto &&item : this->items())
{
@@ -1382,7 +1383,7 @@ void SplitNotebook::addCustomButtons()
settingsBtn->setIcon(NotebookButton::Settings);
QObject::connect(settingsBtn, &NotebookButton::leftClicked, [this] {
getApp()->windows->showSettingsDialog(this);
getIApp()->getWindows()->showSettingsDialog(this);
});
// account
@@ -1396,7 +1397,7 @@ void SplitNotebook::addCustomButtons()
userBtn->setIcon(NotebookButton::User);
QObject::connect(userBtn, &NotebookButton::leftClicked, [this, userBtn] {
getApp()->windows->showAccountSelectPopup(
getIApp()->getWindows()->showAccountSelectPopup(
this->mapToGlobal(userBtn->rect().bottomRight()));
});
@@ -1409,7 +1410,7 @@ void SplitNotebook::addCustomButtons()
this->streamerModeIcon_ = this->addCustomButton();
QObject::connect(this->streamerModeIcon_, &NotebookButton::leftClicked,
[this] {
getApp()->windows->showSettingsDialog(
getIApp()->getWindows()->showSettingsDialog(
this, SettingsDialogPreference::StreamerMode);
});
this->signalHolder_.managedConnect(getApp()->streamerModeChanged, [this]() {
+1 -1
View File
@@ -52,7 +52,7 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
});
this->updateFont();
auto *windows = getApp()->windows;
auto *windows = getIApp()->getWindows();
this->connections_.managedConnect(windows->gifRepaintRequested, [this] {
if (!this->isVisible())
{
+14 -14
View File
@@ -61,7 +61,7 @@ Window::Window(WindowType type, QWidget *parent)
#endif
this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] {
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->onAccountSelected();
}));
this->onAccountSelected();
@@ -75,7 +75,7 @@ Window::Window(WindowType type, QWidget *parent)
this->resize(int(300 * this->scale()), int(500 * this->scale()));
}
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated,
this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() {
this->clearShortcuts();
this->addShortcuts();
@@ -105,7 +105,7 @@ bool Window::event(QEvent *event)
switch (event->type())
{
case QEvent::WindowActivate: {
getApp()->windows->selectedWindow_ = this;
getIApp()->getWindows()->selectedWindow_ = this;
break;
}
@@ -136,15 +136,14 @@ void Window::closeEvent(QCloseEvent *)
{
if (this->type_ == WindowType::Main)
{
auto *app = getApp();
app->windows->save();
app->windows->closeAll();
getIApp()->getWindows()->save();
getIApp()->getWindows()->closeAll();
}
// Ensure selectedWindow_ is never an invalid pointer.
// WindowManager will return the main window if no window is pointed to by
// `selectedWindow_`.
getApp()->windows->selectedWindow_ = nullptr;
getIApp()->getWindows()->selectedWindow_ = nullptr;
this->closed.invoke();
@@ -181,7 +180,7 @@ void Window::addCustomTitlebarButtons()
// settings
this->addTitleBarButton(TitleBarButtonStyle::Settings, [this] {
getApp()->windows->showSettingsDialog(this);
getIApp()->getWindows()->showSettingsDialog(this);
});
// updates
@@ -191,15 +190,16 @@ void Window::addCustomTitlebarButtons()
// account
this->userLabel_ = this->addTitleBarLabel([this] {
getApp()->windows->showAccountSelectPopup(this->userLabel_->mapToGlobal(
this->userLabel_->rect().bottomLeft()));
getIApp()->getWindows()->showAccountSelectPopup(
this->userLabel_->mapToGlobal(
this->userLabel_->rect().bottomLeft()));
});
this->userLabel_->setMinimumWidth(20 * scale());
// streamer mode
this->streamerModeTitlebarIcon_ =
this->addTitleBarButton(TitleBarButtonStyle::StreamerMode, [this] {
getApp()->windows->showSettingsDialog(
getIApp()->getWindows()->showSettingsDialog(
this, SettingsDialogPreference::StreamerMode);
});
this->signalHolder_.managedConnect(getApp()->streamerModeChanged, [this]() {
@@ -489,7 +489,7 @@ void Window::addShortcuts()
{"toggleLocalR9K",
[](std::vector<QString>) -> QString {
getSettings()->hideSimilar.setValue(!getSettings()->hideSimilar);
getApp()->windows->forceLayoutChannelViews();
getIApp()->getWindows()->forceLayoutChannelViews();
return "";
}},
{"openQuickSwitcher",
@@ -690,7 +690,7 @@ void Window::addShortcuts()
this->addDebugStuff(actions);
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::Window, actions, this);
}
@@ -725,7 +725,7 @@ void Window::addMenuBar()
void Window::onAccountSelected()
{
auto user = getApp()->accounts->twitch.getCurrent();
auto user = getIApp()->getAccounts()->twitch.getCurrent();
// update title (also append username on Linux and MacOS)
QString windowTitle = Version::instance().fullVersion();
+9 -7
View File
@@ -26,7 +26,8 @@ EditHotkeyDialog::EditHotkeyDialog(const std::shared_ptr<Hotkey> hotkey,
this->ui_->easyArgsPicker->setVisible(false);
this->ui_->easyArgsLabel->setVisible(false);
// dynamically add category names to the category picker
for (const auto &[_, hotkeyCategory] : getApp()->hotkeys->categories())
for (const auto &[_, hotkeyCategory] :
getIApp()->getHotkeys()->categories())
{
this->ui_->categoryPicker->addItem(hotkeyCategory.displayName,
hotkeyCategory.name);
@@ -153,7 +154,7 @@ void EditHotkeyDialog::afterEdit()
auto arguments =
parseHotkeyArguments(this->ui_->argumentsEdit->toPlainText());
auto category = getApp()->hotkeys->hotkeyCategoryFromName(
auto category = getIApp()->getHotkeys()->hotkeyCategoryFromName(
this->ui_->categoryPicker->currentData().toString());
if (!category)
{
@@ -165,7 +166,7 @@ void EditHotkeyDialog::afterEdit()
// check if another hotkey with this name exists, accounts for editing a hotkey
bool isEditing = bool(this->data_);
if (getApp()->hotkeys->getHotkeyByName(nameText))
if (getIApp()->getHotkeys()->getHotkeyByName(nameText))
{
// A hotkey with this name already exists
if (isEditing && this->data()->name() == nameText)
@@ -242,7 +243,8 @@ void EditHotkeyDialog::afterEdit()
{
if (keyComboWasEdited || nameWasEdited)
{
if (getApp()->hotkeys->isDuplicate(hotkey, this->data()->name()))
if (getIApp()->getHotkeys()->isDuplicate(hotkey,
this->data()->name()))
{
this->showEditError(
"Keybinding needs to be unique in the category.");
@@ -252,7 +254,7 @@ void EditHotkeyDialog::afterEdit()
}
else
{
if (getApp()->hotkeys->isDuplicate(hotkey, QString()))
if (getIApp()->getHotkeys()->isDuplicate(hotkey, QString()))
{
this->showEditError(
"Keybinding needs to be unique in the category.");
@@ -266,7 +268,7 @@ void EditHotkeyDialog::afterEdit()
void EditHotkeyDialog::updatePossibleActions()
{
const auto &hotkeys = getApp()->hotkeys;
const auto &hotkeys = getIApp()->getHotkeys();
auto category = hotkeys->hotkeyCategoryFromName(
this->ui_->categoryPicker->currentData().toString());
if (!category)
@@ -318,7 +320,7 @@ void EditHotkeyDialog::updateArgumentsInput()
this->ui_->argumentsEdit->setEnabled(true);
return;
}
const auto &hotkeys = getApp()->hotkeys;
const auto &hotkeys = getIApp()->getHotkeys();
auto category = hotkeys->hotkeyCategoryFromName(
this->ui_->categoryPicker->currentData().toString());
if (!category)
+15 -9
View File
@@ -206,7 +206,7 @@ EmotePopup::EmotePopup(QWidget *parent)
, notebook_(new Notebook(this))
{
// this->setStayInScreenRect(true);
this->moveTo(getApp()->windows->emotePopupPos(),
this->moveTo(getIApp()->getWindows()->emotePopupPos(),
widgets::BoundsChecking::DesiredPosition);
auto *layout = new QVBoxLayout();
@@ -273,7 +273,7 @@ EmotePopup::EmotePopup(QWidget *parent)
loadEmojis(*this->viewEmojis_,
getApp()->getEmotes()->getEmojis()->getEmojis());
this->addShortcuts();
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated,
this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() {
this->clearShortcuts();
this->addShortcuts();
@@ -371,7 +371,7 @@ void EmotePopup::addShortcuts()
}},
};
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this);
}
@@ -394,9 +394,12 @@ void EmotePopup::loadChannel(ChannelPtr channel)
auto channelChannel = std::make_shared<Channel>("", Channel::Type::None);
// twitch
addTwitchEmoteSets(
getApp()->accounts->twitch.getCurrent()->accessEmotes()->emoteSets,
*globalChannel, *subChannel, this->channel_->getName());
addTwitchEmoteSets(getIApp()
->getAccounts()
->twitch.getCurrent()
->accessEmotes()
->emoteSets,
*globalChannel, *subChannel, this->channel_->getName());
// global
if (Settings::instance().enableBTTVGlobalEmotes)
@@ -467,8 +470,11 @@ bool EmotePopup::eventFilter(QObject *object, QEvent *event)
void EmotePopup::filterTwitchEmotes(std::shared_ptr<Channel> searchChannel,
const QString &searchText)
{
auto twitchEmoteSets =
getApp()->accounts->twitch.getCurrent()->accessEmotes()->emoteSets;
auto twitchEmoteSets = getIApp()
->getAccounts()
->twitch.getCurrent()
->accessEmotes()
->emoteSets;
std::vector<std::shared_ptr<TwitchAccount::EmoteSet>> twitchGlobalEmotes{};
for (const auto &set : twitchEmoteSets)
@@ -589,7 +595,7 @@ void EmotePopup::filterEmotes(const QString &searchText)
void EmotePopup::closeEvent(QCloseEvent *event)
{
getApp()->windows->setEmotePopupPos(this->pos());
getIApp()->getWindows()->setEmotePopupPos(this->pos());
BaseWindow::closeEvent(event);
}
+2 -2
View File
@@ -66,8 +66,8 @@ namespace {
pajlada::Settings::Setting<QString>::set(basePath + "/oauthToken",
oauthToken);
getApp()->accounts->twitch.reloadUsers();
getApp()->accounts->twitch.currentUsername = username;
getIApp()->getAccounts()->twitch.reloadUsers();
getIApp()->getAccounts()->twitch.currentUsername = username;
return true;
}
+1 -1
View File
@@ -14,7 +14,7 @@ QualityPopup::QualityPopup(const QString &channelURL, QStringList options)
BaseWindow::DisableLayoutSave,
BaseWindow::BoundsCheckOnShow,
},
static_cast<QWidget *>(&(getApp()->windows->getMainWindow())))
static_cast<QWidget *>(&(getIApp()->getWindows()->getMainWindow())))
, channelURL_(channelURL)
{
this->ui_.selector = new QComboBox(this);
+8 -6
View File
@@ -77,7 +77,7 @@ ReplyThreadPopup::ReplyThreadPopup(bool closeAutomatically, Split *split)
{"search", nullptr},
};
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this);
// initialize UI
@@ -98,7 +98,7 @@ ReplyThreadPopup::ReplyThreadPopup(bool closeAutomatically, Split *split)
new SplitInput(this, this->split_, this->ui_.threadView, false);
this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] {
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->updateInputUI();
}));
@@ -284,7 +284,7 @@ void ReplyThreadPopup::updateInputUI()
this->ui_.replyInput->setVisible(channel->isWritable());
auto user = getApp()->accounts->twitch.getCurrent();
auto user = getIApp()->getAccounts()->twitch.getCurrent();
QString placeholderText;
if (user->isAnon())
@@ -293,9 +293,11 @@ void ReplyThreadPopup::updateInputUI()
}
else
{
placeholderText =
QStringLiteral("Reply as %1...")
.arg(getApp()->accounts->twitch.getCurrent()->getUserName());
placeholderText = QStringLiteral("Reply as %1...")
.arg(getIApp()
->getAccounts()
->twitch.getCurrent()
->getUserName());
}
this->ui_.replyInput->setPlaceholderText(placeholderText);
+1 -1
View File
@@ -615,7 +615,7 @@ void SelectChannelDialog::addShortcuts()
actions.emplace("openTab", nullptr);
}
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this);
}
+4 -4
View File
@@ -54,7 +54,7 @@ SettingsDialog::SettingsDialog(QWidget *parent)
this->overrideBackgroundColor_ = QColor("#111111");
this->addShortcuts();
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated,
this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() {
this->clearShortcuts();
this->addShortcuts();
@@ -78,13 +78,13 @@ void SettingsDialog::addShortcuts()
{"openTab", nullptr},
};
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this);
}
void SettingsDialog::setSearchPlaceholderText()
{
QString searchHotkey;
auto searchSeq = getApp()->hotkeys->getDisplaySequence(
auto searchSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::PopupWindow, "search");
if (!searchSeq.isEmpty())
{
@@ -432,7 +432,7 @@ void SettingsDialog::onOkClicked()
{
if (!getApp()->getArgs().dontSaveSettings)
{
getApp()->commands->save();
getIApp()->getCommands()->save();
pajlada::Settings::SettingManager::gSave();
}
this->close();
+22 -19
View File
@@ -56,7 +56,7 @@ namespace {
{
button.assign(copyButton);
}
button->setPixmap(getApp()->themes->buttons.copy);
button->setPixmap(getIApp()->getThemes()->buttons.copy);
button->setScaleIndependantSize(18, 18);
button->setDim(Button::Dim::Lots);
button->setToolTip(tooltip);
@@ -226,7 +226,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
.arg(calculateTimeoutDuration(button));
}
msg = getApp()->commands->execCommand(
msg = getIApp()->getCommands()->execCommand(
msg, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(msg);
@@ -245,7 +245,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
{"search", nullptr},
};
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::PopupWindow, actions, this);
auto layers = LayoutCreator<QWidget>(this->getLayoutContainer())
@@ -299,7 +299,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
"Open channel in a new popup window", this,
[loginName] {
auto *app = getApp();
auto &window = app->windows->createWindow(
auto &window = app->getWindows()->createWindow(
WindowType::Popup, true);
auto *split = window.getNotebook()
.getOrAddSelectedPage()
@@ -314,7 +314,8 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
getApp()->twitch->getOrAddChannel(
loginName);
auto &nb = getApp()
->windows->getMainWindow()
->getWindows()
->getMainWindow()
.getNotebook();
SplitContainer *container = nb.addPage(true);
Split *split = new Split(container);
@@ -414,25 +415,25 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
QObject::connect(mod.getElement(), &Button::leftClicked, [this] {
QString value = "/mod " + this->userName_;
value = getApp()->commands->execCommand(
value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value);
});
QObject::connect(unmod.getElement(), &Button::leftClicked, [this] {
QString value = "/unmod " + this->userName_;
value = getApp()->commands->execCommand(
value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value);
});
QObject::connect(vip.getElement(), &Button::leftClicked, [this] {
QString value = "/vip " + this->userName_;
value = getApp()->commands->execCommand(
value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value);
});
QObject::connect(unvip.getElement(), &Button::leftClicked, [this] {
QString value = "/unvip " + this->userName_;
value = getApp()->commands->execCommand(
value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value);
});
@@ -450,9 +451,11 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
if (twitchChannel)
{
bool isMyself =
QString::compare(
getApp()->accounts->twitch.getCurrent()->getUserName(),
this->userName_, Qt::CaseInsensitive) == 0;
QString::compare(getIApp()
->getAccounts()
->twitch.getCurrent()
->getUserName(),
this->userName_, Qt::CaseInsensitive) == 0;
visibilityModButtons =
twitchChannel->isBroadcaster() && !isMyself;
@@ -497,7 +500,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
if (this->underlyingChannel_)
{
QString value = "/ban " + this->userName_;
value = getApp()->commands->execCommand(
value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value);
@@ -508,7 +511,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
if (this->underlyingChannel_)
{
QString value = "/unban " + this->userName_;
value = getApp()->commands->execCommand(
value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value);
@@ -521,7 +524,7 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, Split *split)
QString value = "/timeout " + this->userName_ + " " +
QString::number(arg);
value = getApp()->commands->execCommand(
value = getIApp()->getCommands()->execCommand(
value, this->underlyingChannel_, false);
this->underlyingChannel_->sendMessage(value);
@@ -594,7 +597,7 @@ void UserInfoPopup::installEvents()
QObject::connect(
this->ui_.block, &QCheckBox::stateChanged,
[this](int newState) mutable {
auto currentUser = getApp()->accounts->twitch.getCurrent();
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
const auto reenableBlockCheckbox = [this] {
this->ui_.block->setEnabled(true);
@@ -611,7 +614,7 @@ void UserInfoPopup::installEvents()
case Qt::CheckState::Unchecked: {
this->ui_.block->setEnabled(false);
getApp()->accounts->twitch.getCurrent()->unblockUser(
getIApp()->getAccounts()->twitch.getCurrent()->unblockUser(
this->userId_, this,
[this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage(
@@ -638,7 +641,7 @@ void UserInfoPopup::installEvents()
case Qt::CheckState::Checked: {
this->ui_.block->setEnabled(false);
getApp()->accounts->twitch.getCurrent()->blockUser(
getIApp()->getAccounts()->twitch.getCurrent()->blockUser(
this->userId_, this,
[this, reenableBlockCheckbox, currentUser] {
this->channel_->addMessage(makeSystemMessage(
@@ -795,7 +798,7 @@ void UserInfoPopup::updateLatestMessages()
void UserInfoPopup::updateUserData()
{
std::weak_ptr<bool> hack = this->lifetimeHack_;
auto currentUser = getApp()->accounts->twitch.getCurrent();
auto currentUser = getIApp()->getAccounts()->twitch.getCurrent();
const auto onUserFetchFailed = [this, hack] {
if (!hack.lock())
@@ -21,9 +21,8 @@ NewPopupItem::NewPopupItem(const QString &channelName)
void NewPopupItem::action()
{
auto *app = getApp();
auto channel = app->twitch->getOrAddChannel(this->channelName_);
app->windows->openInPopup(channel);
auto channel = getApp()->twitch->getOrAddChannel(this->channelName_);
getIApp()->getWindows()->openInPopup(channel);
}
void NewPopupItem::paint(QPainter *painter, const QRect &rect) const
@@ -32,9 +31,10 @@ void NewPopupItem::paint(QPainter *painter, const QRect &rect) const
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(getApp()->themes->splits.header.text);
painter->setPen(getIApp()->getThemes()->splits.header.text);
painter->setBrush(Qt::SolidPattern);
painter->setFont(getApp()->fonts->getFont(FontStyle::UiMediumBold, 1.0));
painter->setFont(
getIApp()->getFonts()->getFont(FontStyle::UiMediumBold, 1.0));
QRect iconRect(rect.topLeft(), ICON_SIZE);
this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter);
+3 -2
View File
@@ -37,9 +37,10 @@ void NewTabItem::paint(QPainter *painter, const QRect &rect) const
painter->setRenderHint(QPainter::Antialiasing, true);
// TODO(leon): Right pen/brush/font settings?
painter->setPen(getApp()->themes->splits.header.text);
painter->setPen(getIApp()->getThemes()->splits.header.text);
painter->setBrush(Qt::SolidPattern);
painter->setFont(getApp()->fonts->getFont(FontStyle::UiMediumBold, 1.0));
painter->setFont(
getIApp()->getFonts()->getFont(FontStyle::UiMediumBold, 1.0));
QRect iconRect(rect.topLeft(), ICON_SIZE);
this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter);
@@ -21,11 +21,11 @@ void SwitchSplitItem::action()
{
if (this->split_)
{
getApp()->windows->select(this->split_);
getIApp()->getWindows()->select(this->split_);
}
else if (this->container_)
{
getApp()->windows->select(this->container_);
getIApp()->getWindows()->select(this->container_);
}
}
@@ -36,9 +36,10 @@ void SwitchSplitItem::paint(QPainter *painter, const QRect &rect) const
painter->setRenderHint(QPainter::Antialiasing, true);
// TODO(leon): Right pen/brush/font settings?
painter->setPen(getApp()->themes->splits.header.text);
painter->setPen(getIApp()->getThemes()->splits.header.text);
painter->setBrush(Qt::SolidPattern);
painter->setFont(getApp()->fonts->getFont(FontStyle::UiMediumBold, 1.0));
painter->setFont(
getIApp()->getFonts()->getFont(FontStyle::UiMediumBold, 1.0));
QRect iconRect(rect.topLeft(), ICON_SIZE);
this->icon_.paint(painter, iconRect, Qt::AlignLeft | Qt::AlignVCenter);
@@ -58,7 +59,8 @@ void SwitchSplitItem::paint(QPainter *painter, const QRect &rect) const
QRect(leftTextRect.topRight(),
QSize(0.7 * availableTextWidth, iconRect.height()));
painter->setFont(getApp()->fonts->getFont(FontStyle::UiMedium, 1.0));
painter->setFont(
getIApp()->getFonts()->getFont(FontStyle::UiMedium, 1.0));
painter->drawText(rightTextRect, Qt::AlignRight | Qt::AlignVCenter,
this->container_->getTab()->getTitle());
}
+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;
}
+3 -3
View File
@@ -26,8 +26,8 @@ AccountsPage::AccountsPage()
EditableModelView *view =
layout
.emplace<EditableModelView>(app->accounts->createModel(nullptr),
false)
.emplace<EditableModelView>(
app->getAccounts()->createModel(nullptr), false)
.getElement();
view->getTableView()->horizontalHeader()->setVisible(false);
@@ -63,7 +63,7 @@ AccountsPage::AccountsPage()
// return;
// }
// getApp()->accounts->Twitch.removeUser(selectedUser);
// getIApp()->getAccounts()->Twitch.removeUser(selectedUser);
// });
}
+6 -5
View File
@@ -38,16 +38,17 @@ CommandPage::CommandPage()
LayoutCreator<CommandPage> layoutCreator(this);
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
EditableModelView *view =
layout.emplace<EditableModelView>(app->commands->createModel(nullptr))
.getElement();
EditableModelView *view = layout
.emplace<EditableModelView>(
app->getCommands()->createModel(nullptr))
.getElement();
view->setTitles({"Trigger", "Command", "Show In\nMessage Menu"});
view->getTableView()->horizontalHeader()->setSectionResizeMode(
1, QHeaderView::Stretch);
// We can safely ignore this signal connection since we own the view
std::ignore = view->addButtonPressed.connect([] {
getApp()->commands->items.append(
getIApp()->getCommands()->items.append(
Command{"/command", "I made a new command HeyGuys"});
});
@@ -66,7 +67,7 @@ CommandPage::CommandPage()
{
if (int index = line.indexOf(' '); index != -1)
{
getApp()->commands->items.insert(
getIApp()->getCommands()->items.insert(
Command(line.mid(0, index), line.mid(index + 1)));
}
}
+12 -11
View File
@@ -123,8 +123,8 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addTitle("Interface");
layout.addDropdown<QString>(
"Theme", getApp()->themes->availableThemes(),
getApp()->themes->themeName,
"Theme", getIApp()->getThemes()->availableThemes(),
getIApp()->getThemes()->themeName,
[](const auto *combo, const auto &themeKey) {
return combo->findData(themeKey, Qt::UserRole);
},
@@ -135,7 +135,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addDropdown<QString>(
"Font", {"Segoe UI", "Arial", "Choose..."},
getApp()->fonts->chatFontFamily,
getIApp()->getFonts()->chatFontFamily,
[](auto val) {
return val;
},
@@ -144,7 +144,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
});
layout.addDropdown<int>(
"Font size", {"9pt", "10pt", "12pt", "14pt", "16pt", "20pt"},
getApp()->fonts->chatFontSize,
getIApp()->getFonts()->chatFontSize,
[](auto val) {
return QString::number(val) + "pt";
},
@@ -241,7 +241,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addCheckbox("Show message reply button", s.showReplyButton, false,
"Show a reply button next to every chat message");
auto removeTabSeq = getApp()->hotkeys->getDisplaySequence(
auto removeTabSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "removeTab");
QString removeTabShortcut = "an assigned hotkey (Window -> remove tab)";
if (!removeTabSeq.isEmpty())
@@ -262,7 +262,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
#endif
if (!BaseWindow::supportsCustomWindowFrame())
{
auto settingsSeq = getApp()->hotkeys->getDisplaySequence(
auto settingsSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "openSettings");
QString shortcut = " (no key bound to open them otherwise)";
// TODO: maybe prevent the user from locking themselves out of the settings?
@@ -858,7 +858,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"Show the stream title");
layout.addSubtitle("R9K");
auto toggleLocalr9kSeq = getApp()->hotkeys->getDisplaySequence(
auto toggleLocalr9kSeq = getIApp()->getHotkeys()->getDisplaySequence(
HotkeyCategory::Window, "toggleLocalR9K");
QString toggleLocalr9kShortcut =
"an assigned hotkey (Window -> Toggle local R9K)";
@@ -878,7 +878,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
s.shownSimilarTriggerHighlights);
s.hideSimilar.connect(
[]() {
getApp()->windows->forceLayoutChannelViews();
getIApp()->getWindows()->forceLayoutChannelViews();
},
false);
layout.addDropdown<float>(
@@ -940,10 +940,10 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addCustomCheckbox(
"Restart on crash (requires restart)",
[] {
return getApp()->crashHandler->shouldRecover();
return getIApp()->getCrashHandler()->shouldRecover();
},
[](bool on) {
return getApp()->crashHandler->saveShouldRecover(on);
return getIApp()->getCrashHandler()->saveShouldRecover(on);
},
"When possible, restart Chatterino if the program crashes");
@@ -1251,7 +1251,8 @@ QString GeneralPage::getFont(const DropdownArgs &args) const
{
args.combobox->setCurrentIndex(0);
args.combobox->setEditText("Choosing...");
QFontDialog dialog(getApp()->fonts->getFont(FontStyle::ChatMedium, 1.));
QFontDialog dialog(
getIApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.));
auto ok = bool();
auto font = dialog.getFont(&ok, this->window());
@@ -197,7 +197,7 @@ ComboBox *GeneralPageView::addDropdown(
QObject::connect(combo, &QComboBox::currentTextChanged,
[&setting](const QString &newValue) {
setting = newValue;
getApp()->windows->forceLayoutChannelViews();
getIApp()->getWindows()->forceLayoutChannelViews();
});
return combo;
@@ -203,7 +203,7 @@ public:
setValue = std::move(setValue)](const int newIndex) {
setting = setValue(DropdownArgs{combo->itemText(newIndex),
combo->currentIndex(), combo});
getApp()->windows->forceLayoutChannelViews();
getIApp()->getWindows()->forceLayoutChannelViews();
});
return combo;
@@ -255,7 +255,7 @@ public:
setValue = std::move(setValue)](const int newIndex) {
setting = setValue(DropdownArgs{combo->itemText(newIndex),
combo->currentIndex(), combo});
getApp()->windows->forceLayoutChannelViews();
getIApp()->getWindows()->forceLayoutChannelViews();
});
return combo;
@@ -300,7 +300,7 @@ public:
// Instead, it's up to the getters to make sure that the setting is legic - see the enum_cast above
// You could also use the settings `getEnum` function
setting = newText;
getApp()->windows->forceLayoutChannelViews();
getIApp()->getWindows()->forceLayoutChannelViews();
});
return combo;
+1 -1
View File
@@ -120,7 +120,7 @@ void IgnoresPage::onShow()
{
auto *app = getApp();
auto user = app->accounts->twitch.getCurrent();
auto user = app->getAccounts()->twitch.getCurrent();
if (user->isAnon())
{
@@ -22,7 +22,7 @@ using namespace chatterino;
void tableCellClicked(const QModelIndex &clicked, EditableModelView *view,
HotkeyModel *model)
{
auto hotkey = getApp()->hotkeys->getHotkeyByName(
auto hotkey = getIApp()->getHotkeys()->getHotkeyByName(
clicked.siblingAtColumn(0).data(Qt::EditRole).toString());
if (!hotkey)
{
@@ -34,8 +34,8 @@ void tableCellClicked(const QModelIndex &clicked, EditableModelView *view,
if (wasAccepted)
{
auto newHotkey = dialog.data();
getApp()->hotkeys->replaceHotkey(hotkey->name(), newHotkey);
getApp()->hotkeys->save();
getIApp()->getHotkeys()->replaceHotkey(hotkey->name(), newHotkey);
getIApp()->getHotkeys()->save();
}
}
@@ -48,7 +48,7 @@ KeyboardSettingsPage::KeyboardSettingsPage()
LayoutCreator<KeyboardSettingsPage> layoutCreator(this);
auto layout = layoutCreator.emplace<QVBoxLayout>();
auto *model = getApp()->hotkeys->createModel(nullptr);
auto *model = getIApp()->getHotkeys()->createModel(nullptr);
EditableModelView *view =
layout.emplace<EditableModelView>(model).getElement();
@@ -68,8 +68,8 @@ KeyboardSettingsPage::KeyboardSettingsPage()
if (wasAccepted)
{
auto newHotkey = dialog.data();
getApp()->hotkeys->hotkeys_.append(newHotkey);
getApp()->hotkeys->save();
getIApp()->getHotkeys()->hotkeys_.append(newHotkey);
getIApp()->getHotkeys()->save();
}
});
@@ -87,7 +87,7 @@ KeyboardSettingsPage::KeyboardSettingsPage()
if (reply == QMessageBox::Yes)
{
getApp()->hotkeys->resetToDefaults();
getIApp()->getHotkeys()->resetToDefaults();
}
});
view->addCustomButton(resetEverything);
@@ -93,7 +93,7 @@ NotificationPage::NotificationPage()
EditableModelView *view =
twitchChannels
.emplace<EditableModelView>(
getApp()->notifications->createModel(
getIApp()->getNotifications()->createModel(
nullptr, Platform::Twitch))
.getElement();
view->setTitles({"Twitch channels"});
@@ -112,7 +112,8 @@ NotificationPage::NotificationPage()
// We can safely ignore this signal connection since we own the view
std::ignore = view->addButtonPressed.connect([] {
getApp()
->notifications->channelMap[Platform::Twitch]
->getNotifications()
->channelMap[Platform::Twitch]
.append("channel");
});
}
+3 -3
View File
@@ -80,7 +80,7 @@ void PluginsPage::rebuildContent()
this->scrollAreaWidget_.append(this->dataFrame_);
auto layout = frame.setLayoutType<QVBoxLayout>();
layout->setParent(this->dataFrame_);
for (const auto &[id, plugin] : getApp()->plugins->plugins())
for (const auto &[id, plugin] : getIApp()->getPlugins()->plugins())
{
auto groupHeaderText =
QString("%1 (%2, from %3)")
@@ -185,7 +185,7 @@ void PluginsPage::rebuildContent()
val.push_back(name);
}
getSettings()->enabledPlugins.setValue(val);
getApp()->plugins->reload(name);
getIApp()->getPlugins()->reload(name);
this->rebuildContent();
});
pluginEntry->addRow(toggleButton);
@@ -194,7 +194,7 @@ void PluginsPage::rebuildContent()
auto *reloadButton = new QPushButton("Reload", this->dataFrame_);
QObject::connect(reloadButton, &QPushButton::pressed,
[name = id, this]() {
getApp()->plugins->reload(name);
getIApp()->getPlugins()->reload(name);
this->rebuildContent();
});
pluginEntry->addRow(reloadButton);
+1 -1
View File
@@ -108,7 +108,7 @@ QCheckBox *SettingsPage::createCheckBox(
QObject::connect(checkbox, &QCheckBox::toggled, this,
[&setting](bool state) {
setting = state;
getApp()->windows->forceLayoutChannelViews();
getIApp()->getWindows()->forceLayoutChannelViews();
});
return checkbox;
+28 -23
View File
@@ -241,7 +241,7 @@ Split::Split(QWidget *parent)
// update placeholder text on Twitch account change and channel change
this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] {
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->updateInputPlaceholder();
}));
this->signalHolder_.managedConnect(channelChanged, [this] {
@@ -427,7 +427,8 @@ Split::Split(QWidget *parent)
}
}
QPointer<ResizingTextEdit> edit = this->input_->ui_.textEdit;
getApp()->imageUploader->upload(source, this->getChannel(), edit);
getIApp()->getImageUploader()->upload(source, this->getChannel(),
edit);
});
getSettings()->imageUploaderEnabled.connect(
@@ -436,7 +437,7 @@ Split::Split(QWidget *parent)
},
this->signalHolder_);
this->addShortcuts();
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated,
this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() {
this->clearShortcuts();
this->addShortcuts();
@@ -689,7 +690,7 @@ void Split::addShortcuts()
<< "runCommand hotkey called without arguments!";
return "runCommand hotkey called without arguments!";
}
QString command = getApp()->commands->execCommand(
QString command = getIApp()->getCommands()->execCommand(
arguments.at(0).replace('\n', ' '), this->getChannel(), false);
this->getChannel()->sendMessage(command);
return "";
@@ -724,24 +725,24 @@ void Split::addShortcuts()
if (mode == 0)
{
getApp()->notifications->removeChannelNotification(
getIApp()->getNotifications()->removeChannelNotification(
this->getChannel()->getName(), Platform::Twitch);
}
else if (mode == 1)
{
getApp()->notifications->addChannelNotification(
getIApp()->getNotifications()->addChannelNotification(
this->getChannel()->getName(), Platform::Twitch);
}
else
{
getApp()->notifications->updateChannelNotification(
getIApp()->getNotifications()->updateChannelNotification(
this->getChannel()->getName(), Platform::Twitch);
}
return "";
}},
};
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::Split, actions, this);
}
@@ -770,7 +771,7 @@ void Split::updateInputPlaceholder()
return;
}
auto user = getApp()->accounts->twitch.getCurrent();
auto user = getIApp()->getAccounts()->twitch.getCurrent();
QString placeholderText;
if (user->isAnon())
@@ -779,9 +780,11 @@ void Split::updateInputPlaceholder()
}
else
{
placeholderText =
QString("Send message as %1...")
.arg(getApp()->accounts->twitch.getCurrent()->getUserName());
placeholderText = QString("Send message as %1...")
.arg(getIApp()
->getAccounts()
->twitch.getCurrent()
->getUserName());
}
this->input_->ui_.textEdit->setPlaceholderText(placeholderText);
@@ -789,7 +792,7 @@ void Split::updateInputPlaceholder()
void Split::joinChannelInNewTab(ChannelPtr channel)
{
auto &nb = getApp()->windows->getMainWindow().getNotebook();
auto &nb = getIApp()->getWindows()->getMainWindow().getNotebook();
SplitContainer *container = nb.addPage(true);
Split *split = new Split(container);
@@ -889,7 +892,7 @@ void Split::setChannel(IndirectChannel newChannel)
this->actionRequested.invoke(Action::RefreshTab);
// Queue up save because: Split channel changed
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
}
void Split::setModerationMode(bool value)
@@ -983,7 +986,7 @@ void Split::keyReleaseEvent(QKeyEvent *event)
void Split::resizeEvent(QResizeEvent *event)
{
// Queue up save because: Split resized
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
BaseWidget::resizeEvent(event);
@@ -1073,7 +1076,7 @@ void Split::explainSplitting()
void Split::popup()
{
auto *app = getApp();
Window &window = app->windows->createWindow(WindowType::Popup);
Window &window = app->getWindows()->createWindow(WindowType::Popup);
Split *split = new Split(static_cast<SplitContainer *>(
window.getNotebook().getOrAddSelectedPage()));
@@ -1104,7 +1107,8 @@ void Split::openInBrowser()
void Split::openWhispersInBrowser()
{
auto userName = getApp()->accounts->twitch.getCurrent()->getUserName();
auto userName =
getIApp()->getAccounts()->twitch.getCurrent()->getUserName();
QDesktopServices::openUrl("https://twitch.tv/popout/moderator/" + userName +
"/whispers");
}
@@ -1191,7 +1195,8 @@ void Split::showChatterList()
auto formatListItemText = [](QString text) {
auto *item = new QListWidgetItem();
item->setText(text);
item->setFont(getApp()->fonts->getFont(FontStyle::ChatMedium, 1.0));
item->setFont(
getIApp()->getFonts()->getFont(FontStyle::ChatMedium, 1.0));
return item;
};
@@ -1241,7 +1246,7 @@ void Split::showChatterList()
auto loadChatters = [=](auto modList, auto vipList, bool isBroadcaster) {
getHelix()->getChatters(
twitchChannel->roomId(),
getApp()->accounts->twitch.getCurrent()->getUserId(), 50000,
getIApp()->getAccounts()->twitch.getCurrent()->getUserId(), 50000,
[=](auto chatters) {
auto broadcaster = channel->getName().toLower();
QStringList chatterList;
@@ -1406,8 +1411,8 @@ void Split::showChatterList()
}},
};
getApp()->hotkeys->shortcutsForCategory(HotkeyCategory::PopupWindow,
actions, chatterDock);
getIApp()->getHotkeys()->shortcutsForCategory(HotkeyCategory::PopupWindow,
actions, chatterDock);
dockVbox->addWidget(searchBar);
dockVbox->addWidget(loadingLabel);
@@ -1470,7 +1475,7 @@ void Split::showSearch(bool singleChannel)
}
// Pass every ChannelView for every Split across the app to the search popup
auto &notebook = getApp()->windows->getMainWindow().getNotebook();
auto &notebook = getIApp()->getWindows()->getMainWindow().getNotebook();
for (int i = 0; i < notebook.getPageCount(); ++i)
{
auto *container = dynamic_cast<SplitContainer *>(notebook.getPageAt(i));
@@ -1489,7 +1494,7 @@ void Split::showSearch(bool singleChannel)
void Split::reloadChannelAndSubscriberEmotes()
{
auto channel = this->getChannel();
getApp()->accounts->twitch.getCurrent()->loadEmotes(channel);
getIApp()->getAccounts()->twitch.getCurrent()->loadEmotes(channel);
if (auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
{
+13 -13
View File
@@ -131,7 +131,7 @@ Split *SplitContainer::appendNewSplit(bool openChannelNameDialog)
void SplitContainer::insertSplit(Split *split, InsertOptions &&options)
{
// Queue up save because: Split added
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
assertInGuiThread();
@@ -345,7 +345,7 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split)
SplitContainer::Position SplitContainer::deleteSplit(Split *split)
{
// Queue up save because: Split removed
getApp()->windows->queueSave();
getIApp()->getWindows()->queueSave();
assertInGuiThread();
assert(split != nullptr);
@@ -614,8 +614,8 @@ void SplitContainer::paintEvent(QPaintEvent * /*event*/)
painter.setPen(this->theme->splits.header.text);
const auto font =
getApp()->fonts->getFont(FontStyle::ChatMedium, this->scale());
const auto font = getIApp()->getFonts()->getFont(FontStyle::ChatMedium,
this->scale());
painter.setFont(font);
QString text = "Click to add a split";
@@ -634,7 +634,7 @@ void SplitContainer::paintEvent(QPaintEvent * /*event*/)
}
else
{
if (getApp()->themes->isLightTheme())
if (getIApp()->getThemes()->isLightTheme())
{
painter.fillRect(rect(), QColor("#999"));
}
@@ -646,8 +646,8 @@ void SplitContainer::paintEvent(QPaintEvent * /*event*/)
for (DropRect &dropRect : this->dropRects_)
{
QColor border = getApp()->themes->splits.dropTargetRectBorder;
QColor background = getApp()->themes->splits.dropTargetRect;
QColor border = getIApp()->getThemes()->splits.dropTargetRectBorder;
QColor background = getIApp()->getThemes()->splits.dropTargetRect;
if (!dropRect.rect.contains(this->mouseOverPoint_))
{
@@ -774,7 +774,7 @@ void SplitContainer::applyFromDescriptor(const NodeDescriptor &rootNode)
void SplitContainer::popup()
{
Window &window = getApp()->windows->createWindow(WindowType::Popup);
Window &window = getIApp()->getWindows()->createWindow(WindowType::Popup);
auto *popupContainer = window.getNotebook().getOrAddSelectedPage();
QJsonObject encodedTab;
@@ -1436,15 +1436,15 @@ void SplitContainer::DropOverlay::paintEvent(QPaintEvent * /*event*/)
{
if (!foundMover && rect.rect.contains(this->mouseOverPoint_))
{
painter.setBrush(getApp()->themes->splits.dropPreview);
painter.setPen(getApp()->themes->splits.dropPreviewBorder);
painter.setBrush(getIApp()->getThemes()->splits.dropPreview);
painter.setPen(getIApp()->getThemes()->splits.dropPreviewBorder);
foundMover = true;
}
else
{
painter.setBrush(QColor(0, 0, 0, 0));
painter.setPen(QColor(0, 0, 0, 0));
// painter.setPen(getApp()->themes->splits.dropPreviewBorder);
// painter.setPen(getIApp()->getThemes()->splits.dropPreviewBorder);
}
painter.drawRect(rect.rect);
@@ -1526,10 +1526,10 @@ SplitContainer::ResizeHandle::ResizeHandle(SplitContainer *_parent)
void SplitContainer::ResizeHandle::paintEvent(QPaintEvent * /*event*/)
{
QPainter painter(this);
painter.setPen(QPen(getApp()->themes->splits.resizeHandle, 2));
painter.setPen(QPen(getIApp()->getThemes()->splits.resizeHandle, 2));
painter.fillRect(this->rect(),
getApp()->themes->splits.resizeHandleBackground);
getIApp()->getThemes()->splits.resizeHandleBackground);
if (this->vertical_)
{
+7 -7
View File
@@ -246,7 +246,7 @@ SplitHeader::SplitHeader(Split *split)
});
this->bSignals_.emplace_back(
getApp()->accounts->twitch.currentUserChanged.connect([this] {
getIApp()->getAccounts()->twitch.currentUserChanged.connect([this] {
this->updateModerationModeIcon();
}));
@@ -295,7 +295,7 @@ void SplitHeader::initializeLayout()
case Qt::LeftButton:
if (getSettings()->moderationActions.empty())
{
getApp()->windows->showSettingsDialog(
getIApp()->getWindows()->showSettingsDialog(
this, SettingsDialogPreference::
ModerationActions);
this->split_->setModerationMode(true);
@@ -313,7 +313,7 @@ void SplitHeader::initializeLayout()
case Qt::RightButton:
case Qt::MiddleButton:
getApp()->windows->showSettingsDialog(
getIApp()->getWindows()->showSettingsDialog(
this,
SettingsDialogPreference::ModerationActions);
break;
@@ -363,7 +363,7 @@ void SplitHeader::initializeLayout()
std::unique_ptr<QMenu> SplitHeader::createMainMenu()
{
// top level menu
const auto &h = getApp()->hotkeys;
const auto &h = getIApp()->getHotkeys();
auto menu = std::make_unique<QMenu>();
menu->addAction(
"Change channel", this->split_, &Split::changeChannel,
@@ -533,11 +533,11 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
action->setShortcut(notifySeq);
QObject::connect(moreMenu, &QMenu::aboutToShow, this, [action, this]() {
action->setChecked(getApp()->notifications->isChannelNotified(
action->setChecked(getIApp()->getNotifications()->isChannelNotified(
this->split_->getChannel()->getName(), Platform::Twitch));
});
QObject::connect(action, &QAction::triggered, this, [this]() {
getApp()->notifications->updateChannelNotification(
getIApp()->getNotifications()->updateChannelNotification(
this->split_->getChannel()->getName(), Platform::Twitch);
});
@@ -1034,7 +1034,7 @@ void SplitHeader::reloadSubscriberEmotes()
this->lastReloadedSubEmotes_ = now;
auto channel = this->split_->getChannel();
getApp()->accounts->twitch.getCurrent()->loadEmotes(channel);
getIApp()->getAccounts()->twitch.getCurrent()->loadEmotes(channel);
}
void SplitHeader::reconnect()
+16 -15
View File
@@ -69,7 +69,7 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
this->hideCompletionPopup();
});
this->scaleChangedEvent(this->scale());
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated,
this->signalHolder_.managedConnect(getIApp()->getHotkeys()->onItemsUpdated,
[this]() {
this->clearShortcuts();
this->addShortcuts();
@@ -96,7 +96,7 @@ void SplitInput::initLayout()
auto replyLabel = replyHbox.emplace<QLabel>().assign(&this->ui_.replyLabel);
replyLabel->setAlignment(Qt::AlignLeft);
replyLabel->setFont(
app->fonts->getFont(FontStyle::ChatMedium, this->scale()));
app->getFonts()->getFont(FontStyle::ChatMedium, this->scale()));
replyHbox->addStretch(1);
@@ -157,18 +157,18 @@ void SplitInput::initLayout()
// set edit font
this->ui_.textEdit->setFont(
app->fonts->getFont(FontStyle::ChatMedium, this->scale()));
app->getFonts()->getFont(FontStyle::ChatMedium, this->scale()));
QObject::connect(this->ui_.textEdit, &QTextEdit::cursorPositionChanged,
this, &SplitInput::onCursorPositionChanged);
QObject::connect(this->ui_.textEdit, &QTextEdit::textChanged, this,
&SplitInput::onTextChanged);
this->managedConnections_.managedConnect(
app->fonts->fontChanged, [=, this]() {
app->getFonts()->fontChanged, [=, this]() {
this->ui_.textEdit->setFont(
app->fonts->getFont(FontStyle::ChatMedium, this->scale()));
this->ui_.replyLabel->setFont(
app->fonts->getFont(FontStyle::ChatMediumBold, this->scale()));
app->getFonts()->getFont(FontStyle::ChatMedium, this->scale()));
this->ui_.replyLabel->setFont(app->getFonts()->getFont(
FontStyle::ChatMediumBold, this->scale()));
});
// open emote popup
@@ -213,11 +213,11 @@ void SplitInput::scaleChangedEvent(float scale)
this->setMaximumHeight(this->scaledMaxHeight());
}
this->ui_.textEdit->setFont(
app->fonts->getFont(FontStyle::ChatMedium, scale));
app->getFonts()->getFont(FontStyle::ChatMedium, scale));
this->ui_.textEditLength->setFont(
app->fonts->getFont(FontStyle::ChatMedium, scale));
app->getFonts()->getFont(FontStyle::ChatMedium, scale));
this->ui_.replyLabel->setFont(
app->fonts->getFont(FontStyle::ChatMediumBold, scale));
app->getFonts()->getFont(FontStyle::ChatMediumBold, scale));
}
void SplitInput::themeChangedEvent()
@@ -332,7 +332,7 @@ QString SplitInput::handleSendMessage(const std::vector<QString> &arguments)
message = message.replace('\n', ' ');
QString sendMessage =
getApp()->commands->execCommand(message, c, false);
getIApp()->getCommands()->execCommand(message, c, false);
c->sendMessage(sendMessage);
@@ -363,7 +363,8 @@ QString SplitInput::handleSendMessage(const std::vector<QString> &arguments)
}
message = message.replace('\n', ' ');
QString sendMessage = getApp()->commands->execCommand(message, c, false);
QString sendMessage =
getIApp()->getCommands()->execCommand(message, c, false);
// Reply within TwitchChannel
tc->sendReply(sendMessage, this->replyThread_->id);
@@ -640,7 +641,7 @@ void SplitInput::addShortcuts()
}},
};
this->shortcuts_ = getApp()->hotkeys->shortcutsForCategory(
this->shortcuts_ = getIApp()->getHotkeys()->shortcutsForCategory(
HotkeyCategory::SplitInput, actions, this->parentWidget());
}
@@ -947,8 +948,8 @@ void SplitInput::editTextChanged()
this->textChanged.invoke(text);
text = text.trimmed();
text =
app->commands->execCommand(text, this->split_->getChannel(), true);
text = app->getCommands()->execCommand(text, this->split_->getChannel(),
true);
}
if (text.length() > 0 &&
+2 -2
View File
@@ -268,8 +268,8 @@ void SplitOverlay::paintEvent(QPaintEvent *event)
{
rect.setRight(rect.right() - 1);
rect.setBottom(rect.bottom() - 1);
painter.setPen(getApp()->themes->splits.dropPreviewBorder);
painter.setBrush(getApp()->themes->splits.dropPreview);
painter.setPen(getIApp()->getThemes()->splits.dropPreviewBorder);
painter.setBrush(getIApp()->getThemes()->splits.dropPreview);
painter.drawRect(rect);
}
}