refactor: Remove most raw accesses into Application (#5104)
This commit is contained in:
@@ -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);
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user