Cheats: Update Cheat Manager state on toggling cheats from the list

Fixes a visual desync of these two lists
This commit is contained in:
Silent 2021-08-25 18:59:30 +02:00
parent 6c70d7b8b3
commit c7d0df6081
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1
4 changed files with 16 additions and 6 deletions

View file

@ -179,6 +179,8 @@ void CheatManagerDialog::connectUi()
connect(m_ui.watchTable, &QTableWidget::currentItemChanged, this, &CheatManagerDialog::watchCurrentItemChanged);
connect(m_ui.scanTable, &QTableWidget::itemChanged, this, &CheatManagerDialog::scanItemChanged);
connect(m_ui.watchTable, &QTableWidget::itemChanged, this, &CheatManagerDialog::watchItemChanged);
connect(QtHostInterface::GetInstance(), &QtHostInterface::cheatEnabled, this, &CheatManagerDialog::setCheatCheckState);
}
void CheatManagerDialog::showEvent(QShowEvent* event)
@ -488,12 +490,7 @@ void CheatManagerDialog::activateCheat(u32 index)
}
const bool new_enabled = !cc.enabled;
QTreeWidgetItem* item = getItemForCheatIndex(index);
if (item)
{
QSignalBlocker sb(m_ui.cheatList);
item->setCheckState(0, new_enabled ? Qt::Checked : Qt::Unchecked);
}
setCheatCheckState(index, new_enabled);
QtHostInterface::GetInstance()->executeOnEmulationThread([index, new_enabled]() {
System::GetCheatList()->SetCodeEnabled(index, new_enabled);
@ -501,6 +498,16 @@ void CheatManagerDialog::activateCheat(u32 index)
});
}
void CheatManagerDialog::setCheatCheckState(u32 index, bool checked)
{
QTreeWidgetItem* item = getItemForCheatIndex(index);
if (item)
{
QSignalBlocker sb(m_ui.cheatList);
item->setCheckState(0, checked ? Qt::Checked : Qt::Unchecked);
}
}
void CheatManagerDialog::newCategoryClicked()
{
QString group_name = QInputDialog::getText(this, tr("Add Group"), tr("Group Name:"));

View file

@ -31,6 +31,7 @@ private Q_SLOTS:
void cheatListItemActivated(QTreeWidgetItem* item);
void cheatListItemChanged(QTreeWidgetItem* item, int column);
void activateCheat(u32 index);
void setCheatCheckState(u32 index, bool checked);
void newCategoryClicked();
void addCodeClicked();
void editCodeClicked();

View file

@ -1279,6 +1279,7 @@ void QtHostInterface::setCheatEnabled(quint32 index, bool enabled)
}
SetCheatCodeState(index, enabled, g_settings.auto_load_cheats);
emit cheatEnabled(index, enabled);
}
void QtHostInterface::applyCheat(quint32 index)

View file

@ -148,6 +148,7 @@ Q_SIGNALS:
void inputProfileLoaded();
void mouseModeRequested(bool relative, bool hide_cursor);
void achievementsLoaded(quint32 id, const QString& game_info_string, quint32 total, quint32 points);
void cheatEnabled(quint32 index, bool enabled);
public Q_SLOTS:
void setDefaultSettings();