Qt/CheatManager: Add manual watch address

This commit is contained in:
Connor McLaughlin
2020-12-18 19:04:31 +10:00
parent a6a0b660d2
commit 980aa0a8bc
7 changed files with 66 additions and 38 deletions

View File

@ -8,6 +8,7 @@
#include <QtWidgets/QComboBox>
#include <QtWidgets/QDialog>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QInputDialog>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QScrollBar>
@ -736,4 +737,31 @@ void FillComboBoxWithEmulationSpeeds(QComboBox* cb)
}
}
std::optional<unsigned> PromptForAddress(QWidget* parent, const QString& title, const QString& label)
{
const QString address_str(
QInputDialog::getText(parent, title, qApp->translate("DebuggerWindow", "Enter memory address:")));
if (address_str.isEmpty())
return std::nullopt;
bool ok;
uint address;
if (address_str.startsWith("0x"))
address = address_str.midRef(2).toUInt(&ok, 16);
else if (address_str[0] == '0' && address_str.length() > 1)
address = address_str.midRef(1).toUInt(&ok, 8);
else
address = address_str.toUInt(&ok, 10);
if (!ok)
{
QMessageBox::critical(
parent, title,
qApp->translate("DebuggerWindow", "Invalid address. It should be in hex (0x12345678) or decimal (12345678)"));
return std::nullopt;
}
return address;
}
} // namespace QtUtils