From 93b18412f5a76f6aed8e824680d6443c36da87df Mon Sep 17 00:00:00 2001 From: chaoticgd <43898262+chaoticgd@users.noreply.github.com> Date: Sat, 14 Sep 2024 21:03:49 +0100 Subject: [PATCH] Debugger: Make check box widgets in the symbol tree more responsive --- pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.cpp | 8 ++++++++ pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.h | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.cpp b/pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.cpp index 3d199351be..2922d08ef8 100644 --- a/pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.cpp +++ b/pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.cpp @@ -77,6 +77,7 @@ QWidget* SymbolTreeValueDelegate::createEditor(QWidget* parent, const QStyleOpti { QCheckBox* editor = new QCheckBox(parent); editor->setChecked(value.toBool()); + connect(editor, &QCheckBox::checkStateChanged, this, &SymbolTreeValueDelegate::onCheckBoxStateChanged); result = editor; break; @@ -276,6 +277,13 @@ void SymbolTreeValueDelegate::setModelData(QWidget* editor, QAbstractItemModel* model->setData(index, value, SymbolTreeModel::EDIT_ROLE); } +void SymbolTreeValueDelegate::onCheckBoxStateChanged(Qt::CheckState state) +{ + QCheckBox* check_box = qobject_cast(sender()); + if (check_box) + commitData(check_box); +} + void SymbolTreeValueDelegate::onComboBoxIndexChanged(int index) { QComboBox* combo_box = qobject_cast(sender()); diff --git a/pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.h b/pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.h index 934727fe73..03028297c5 100644 --- a/pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.h +++ b/pcsx2-qt/Debugger/SymbolTree/SymbolTreeDelegates.h @@ -21,8 +21,10 @@ public: void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; protected: - // Without this, setModelData would only be called when a combo box was - // deselected rather than when an option was picked. + // These make it so the values inputted are written back to memory + // immediately when the widgets are interacted with rather than when they + // are deselected. + void onCheckBoxStateChanged(Qt::CheckState state); void onComboBoxIndexChanged(int index); DebugInterface& m_cpu;