summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2022-10-30 04:21:14 -0400
committerGitHub <noreply@github.com>2022-10-30 04:21:14 -0400
commit950e1f94dc73b56309c090d7b04033506b057ae0 (patch)
tree02fc8a81516c70297bfcd05c30ed37e853616784 /Source/Core/DolphinQt/Debugger/MemoryWidget.cpp
parent0628794cb6fb2ee4840131066f3d51667a875a34 (diff)
parent053320b7cf5e1f4363c20edc9275cd352641cbd9 (diff)
Merge pull request #11185 from TryTwo/PR_MemoryWidget_Address_Input_History
MemoryWidget: Make search address a combobox that holds address history.
Diffstat (limited to 'Source/Core/DolphinQt/Debugger/MemoryWidget.cpp')
-rw-r--r--Source/Core/DolphinQt/Debugger/MemoryWidget.cpp39
1 files changed, 32 insertions, 7 deletions
diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp
index f6189ebb62..4019450c3a 100644
--- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp
+++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp
@@ -97,10 +97,13 @@ void MemoryWidget::CreateWidgets()
// Search
auto* m_address_splitter = new QSplitter(Qt::Horizontal);
- m_search_address = new QLineEdit;
+ m_search_address = new QComboBox;
+ m_search_address->setInsertPolicy(QComboBox::InsertAtTop);
+ m_search_address->setDuplicatesEnabled(false);
+ m_search_address->setEditable(true);
+ m_search_address->setMaxVisibleItems(8);
m_search_offset = new QLineEdit;
- m_search_address->setMaxLength(8);
m_search_offset->setMaxLength(9);
m_search_address->setPlaceholderText(tr("Search Address"));
m_search_offset->setPlaceholderText(tr("Offset"));
@@ -297,7 +300,7 @@ void MemoryWidget::CreateWidgets()
void MemoryWidget::ConnectWidgets()
{
- connect(m_search_address, &QLineEdit::textChanged, this, &MemoryWidget::OnSearchAddress);
+ connect(m_search_address, &QComboBox::currentTextChanged, this, &MemoryWidget::OnSearchAddress);
connect(m_search_offset, &QLineEdit::textChanged, this, &MemoryWidget::OnSearchAddress);
connect(m_data_edit, &QLineEdit::textChanged, this, &MemoryWidget::ValidateAndPreviewInputValue);
@@ -479,6 +482,28 @@ void MemoryWidget::OnBPTypeChanged()
void MemoryWidget::SetAddress(u32 address)
{
+ // Store current and target address in combo box
+ const QSignalBlocker blocker(m_search_address);
+ const QString current_text = m_search_address->currentText();
+ const QString target_addr = QString::number(address, 16);
+ bool good;
+ const u32 current_addr = current_text.toUInt(&good, 16);
+
+ if (good)
+ {
+ AddressSpace::Accessors* accessors =
+ AddressSpace::GetAccessors(m_memory_view->GetAddressSpace());
+ good = accessors->IsValidAddress(current_addr);
+ }
+
+ if (m_search_address->findText(current_text) == -1 && good)
+ m_search_address->insertItem(0, current_text);
+
+ if (m_search_address->findText(target_addr) == -1)
+ m_search_address->insertItem(0, target_addr);
+
+ m_search_address->setCurrentText(target_addr);
+
m_memory_view->SetAddress(address);
Settings::Instance().SetMemoryVisible(true);
raise();
@@ -745,8 +770,8 @@ MemoryWidget::TargetAddress MemoryWidget::GetTargetAddress() const
TargetAddress target;
// Returns 0 if conversion fails
- const u32 addr = m_search_address->text().toUInt(&target.is_good_address, 16);
- target.is_good_address |= m_search_address->text().isEmpty();
+ const u32 addr = m_search_address->currentText().toUInt(&target.is_good_address, 16);
+ target.is_good_address |= m_search_address->currentText().isEmpty();
const s32 offset = m_search_offset->text().toInt(&target.is_good_offset, 16);
const u32 neg_offset = offset != std::numeric_limits<s32>::min() ?
-offset :
@@ -789,7 +814,7 @@ void MemoryWidget::FindValue(bool next)
return;
}
- if (!m_search_address->text().isEmpty())
+ if (!m_search_address->currentText().isEmpty())
{
// skip the quoted address so we don't potentially refind the last result
target_addr.address += next ? 1 : -1;
@@ -807,7 +832,7 @@ void MemoryWidget::FindValue(bool next)
u32 offset = *found_addr;
- m_search_address->setText(QStringLiteral("%1").arg(offset, 8, 16, QLatin1Char('0')));
+ m_search_address->setCurrentText(QStringLiteral("%1").arg(offset, 8, 16, QLatin1Char('0')));
m_search_offset->clear();
m_memory_view->SetAddress(offset);