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
+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)