mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
Qt: add validator to patch creator offset lineedit
This commit is contained in:
parent
083b4f0d3b
commit
e8ee5831d3
@ -435,7 +435,7 @@ void debugger_frame::keyPressEvent(QKeyEvent* event)
|
|||||||
dlg.set_input_font(mono, false);
|
dlg.set_input_font(mono, false);
|
||||||
dlg.set_clear_button_enabled(false);
|
dlg.set_clear_button_enabled(false);
|
||||||
dlg.set_button_enabled(QDialogButtonBox::StandardButton::Ok, false);
|
dlg.set_button_enabled(QDialogButtonBox::StandardButton::Ok, false);
|
||||||
dlg.set_validator(new QRegularExpressionValidator(QRegularExpression("^[1-9][0-9]*$")));
|
dlg.set_validator(new QRegularExpressionValidator(QRegularExpression("^[1-9][0-9]*$"), &dlg));
|
||||||
|
|
||||||
u32 max = 0;
|
u32 max = 0;
|
||||||
|
|
||||||
@ -1188,11 +1188,11 @@ void debugger_frame::ShowGotoAddressDialog()
|
|||||||
|
|
||||||
if (const auto thread = get_cpu(); !thread || thread->id_type() != 2)
|
if (const auto thread = get_cpu(); !thread || thread->id_type() != 2)
|
||||||
{
|
{
|
||||||
expression_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,8}$")));
|
expression_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,8}$"), this));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
expression_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,5}$")));
|
expression_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,5}$"), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok/Cancel
|
// Ok/Cancel
|
||||||
|
@ -34,13 +34,13 @@ elf_memory_dumping_dialog::elf_memory_dumping_dialog(u32 ppu_debugger_addr, std:
|
|||||||
m_seg_list->setMinimumWidth(gui::utils::get_label_width(tr("PPU Address: 0x00000000, LS Address: 0x00000, Segment Size: 0x00000, Flags: 0x0")));
|
m_seg_list->setMinimumWidth(gui::utils::get_label_width(tr("PPU Address: 0x00000000, LS Address: 0x00000, Segment Size: 0x00000, Flags: 0x0")));
|
||||||
|
|
||||||
// Address expression input
|
// Address expression input
|
||||||
auto make_hex_edit = [mono](u32 max_digits)
|
auto make_hex_edit = [this, mono](u32 max_digits)
|
||||||
{
|
{
|
||||||
QLineEdit* le = new QLineEdit();
|
QLineEdit* le = new QLineEdit();
|
||||||
le->setFont(mono);
|
le->setFont(mono);
|
||||||
le->setMaxLength(max_digits + 2);
|
le->setMaxLength(max_digits + 2);
|
||||||
le->setPlaceholderText("0x" + QStringLiteral("0").repeated(max_digits));
|
le->setPlaceholderText("0x" + QStringLiteral("0").repeated(max_digits));
|
||||||
le->setValidator(new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^(0[xX])?0*[a-fA-F0-9]{0,%1}$").arg(max_digits))));
|
le->setValidator(new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^(0[xX])?0*[a-fA-F0-9]{0,%1}$").arg(max_digits)), this));
|
||||||
return le;
|
return le;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1633,7 +1633,7 @@ void main_window::DecryptSPRXLibraries()
|
|||||||
dlg->set_input_font(mono, true, '0');
|
dlg->set_input_font(mono, true, '0');
|
||||||
dlg->set_clear_button_enabled(false);
|
dlg->set_clear_button_enabled(false);
|
||||||
dlg->set_button_enabled(QDialogButtonBox::StandardButton::Ok, false);
|
dlg->set_button_enabled(QDialogButtonBox::StandardButton::Ok, false);
|
||||||
dlg->set_validator(new QRegularExpressionValidator(QRegularExpression("^((((((K?L)?I)?C)?=)?0)?x)?[a-fA-F0-9]{0,32}$"))); // HEX only (with additional KLIC=0x prefix for convenience)
|
dlg->set_validator(new QRegularExpressionValidator(QRegularExpression("^((((((K?L)?I)?C)?=)?0)?x)?[a-fA-F0-9]{0,32}$"), this)); // HEX only (with additional KLIC=0x prefix for convenience)
|
||||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
connect(dlg, &input_dialog::text_changed, dlg, [dlg](const QString& text)
|
connect(dlg, &input_dialog::text_changed, dlg, [dlg](const QString& text)
|
||||||
|
@ -92,7 +92,7 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptr<CPUDis
|
|||||||
m_addr_line->setMaxLength(18);
|
m_addr_line->setMaxLength(18);
|
||||||
m_addr_line->setFixedWidth(75);
|
m_addr_line->setFixedWidth(75);
|
||||||
m_addr_line->setFocus();
|
m_addr_line->setFocus();
|
||||||
m_addr_line->setValidator(new QRegularExpressionValidator(QRegularExpression(m_type == thread_type::spu ? "^(0[xX])?0*[a-fA-F0-9]{0,5}$" : "^(0[xX])?0*[a-fA-F0-9]{0,8}$")));
|
m_addr_line->setValidator(new QRegularExpressionValidator(QRegularExpression(m_type == thread_type::spu ? "^(0[xX])?0*[a-fA-F0-9]{0,5}$" : "^(0[xX])?0*[a-fA-F0-9]{0,8}$"), this));
|
||||||
hbox_tools_mem_addr->addWidget(m_addr_line);
|
hbox_tools_mem_addr->addWidget(m_addr_line);
|
||||||
tools_mem_addr->setLayout(hbox_tools_mem_addr);
|
tools_mem_addr->setLayout(hbox_tools_mem_addr);
|
||||||
|
|
||||||
|
@ -31,11 +31,15 @@ patch_creator_dialog::patch_creator_dialog(QWidget* parent)
|
|||||||
, mMonoFont(QFontDatabase::systemFont(QFontDatabase::FixedFont))
|
, mMonoFont(QFontDatabase::systemFont(QFontDatabase::FixedFont))
|
||||||
, mValidColor(gui::utils::get_label_color("log_level_success"))
|
, mValidColor(gui::utils::get_label_color("log_level_success"))
|
||||||
, mInvalidColor(gui::utils::get_label_color("log_level_error"))
|
, mInvalidColor(gui::utils::get_label_color("log_level_error"))
|
||||||
|
, m_offset_validator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?[a-fA-F0-9]{0,8}$"), this))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->patchEdit->setFont(mMonoFont);
|
ui->patchEdit->setFont(mMonoFont);
|
||||||
ui->addPatchOffsetEdit->setFont(mMonoFont);
|
ui->addPatchOffsetEdit->setFont(mMonoFont);
|
||||||
|
ui->addPatchOffsetEdit->setClearButtonEnabled(true);
|
||||||
ui->addPatchValueEdit->setFont(mMonoFont);
|
ui->addPatchValueEdit->setFont(mMonoFont);
|
||||||
|
ui->addPatchValueEdit->setClearButtonEnabled(true);
|
||||||
|
ui->addPatchCommentEdit->setClearButtonEnabled(true);
|
||||||
ui->instructionTable->setFont(mMonoFont);
|
ui->instructionTable->setFont(mMonoFont);
|
||||||
ui->instructionTable->setItemDelegate(new table_item_delegate(this, false));
|
ui->instructionTable->setItemDelegate(new table_item_delegate(this, false));
|
||||||
ui->instructionTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::Fixed);
|
ui->instructionTable->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::Fixed);
|
||||||
@ -66,6 +70,8 @@ patch_creator_dialog::patch_creator_dialog(QWidget* parent)
|
|||||||
connect(ui->addPatchButton, &QAbstractButton::clicked, this, [this]() { add_instruction(ui->instructionTable->rowCount()); });
|
connect(ui->addPatchButton, &QAbstractButton::clicked, this, [this]() { add_instruction(ui->instructionTable->rowCount()); });
|
||||||
|
|
||||||
init_patch_type_bombo_box(ui->addPatchTypeComboBox, patch_type::be32, false);
|
init_patch_type_bombo_box(ui->addPatchTypeComboBox, patch_type::be32, false);
|
||||||
|
connect(ui->addPatchTypeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int index){ update_validator(index, ui->addPatchTypeComboBox, ui->addPatchOffsetEdit); });
|
||||||
|
update_validator(ui->addPatchTypeComboBox->currentIndex(), ui->addPatchTypeComboBox, ui->addPatchOffsetEdit);
|
||||||
|
|
||||||
generate_yml();
|
generate_yml();
|
||||||
}
|
}
|
||||||
@ -198,6 +204,25 @@ void patch_creator_dialog::show_table_menu(const QPoint& pos)
|
|||||||
menu.exec(ui->instructionTable->viewport()->mapToGlobal(pos));
|
menu.exec(ui->instructionTable->viewport()->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void patch_creator_dialog::update_validator(int index, QComboBox* combo_box, QLineEdit* line_edit)
|
||||||
|
{
|
||||||
|
if (index < 0 || !combo_box || !line_edit || !combo_box->itemData(index).canConvert<patch_type>())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (combo_box->itemData(index).value<patch_type>())
|
||||||
|
{
|
||||||
|
case patch_type::move_file:
|
||||||
|
case patch_type::hide_file:
|
||||||
|
line_edit->setValidator(nullptr);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
line_edit->setValidator(m_offset_validator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void patch_creator_dialog::add_instruction(int row)
|
void patch_creator_dialog::add_instruction(int row)
|
||||||
{
|
{
|
||||||
const QString type = ui->addPatchTypeComboBox->currentText();
|
const QString type = ui->addPatchTypeComboBox->currentText();
|
||||||
@ -206,6 +231,25 @@ void patch_creator_dialog::add_instruction(int row)
|
|||||||
const QString comment = ui->addPatchCommentEdit->text();
|
const QString comment = ui->addPatchCommentEdit->text();
|
||||||
|
|
||||||
const patch_type t = patch_engine::get_patch_type(type.toStdString());
|
const patch_type t = patch_engine::get_patch_type(type.toStdString());
|
||||||
|
|
||||||
|
switch (t)
|
||||||
|
{
|
||||||
|
case patch_type::move_file:
|
||||||
|
case patch_type::hide_file:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
int pos = 0;
|
||||||
|
QString text_to_validate = offset;
|
||||||
|
if (m_offset_validator->validate(text_to_validate, pos) == QValidator::Invalid)
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, tr("Offset invalid!"), tr("The patch offset is invalid.\nThe offset has to be a hexadecimal number with 8 digits at most."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QComboBox* combo_box = create_patch_type_bombo_box(t);
|
QComboBox* combo_box = create_patch_type_bombo_box(t);
|
||||||
|
|
||||||
ui->instructionTable->insertRow(std::max(0, std::min(row, ui->instructionTable->rowCount())));
|
ui->instructionTable->insertRow(std::max(0, std::min(row, ui->instructionTable->rowCount())));
|
||||||
|
@ -25,6 +25,7 @@ private:
|
|||||||
QColor mValidColor;
|
QColor mValidColor;
|
||||||
QColor mInvalidColor;
|
QColor mInvalidColor;
|
||||||
bool m_valid = true; // Will be invalidated immediately
|
bool m_valid = true; // Will be invalidated immediately
|
||||||
|
QRegularExpressionValidator* m_offset_validator = nullptr;
|
||||||
|
|
||||||
enum class move_direction
|
enum class move_direction
|
||||||
{
|
{
|
||||||
@ -40,6 +41,8 @@ private:
|
|||||||
static void init_patch_type_bombo_box(QComboBox* combo_box, patch_type set_type, bool searchable);
|
static void init_patch_type_bombo_box(QComboBox* combo_box, patch_type set_type, bool searchable);
|
||||||
QComboBox* create_patch_type_bombo_box(patch_type set_type);
|
QComboBox* create_patch_type_bombo_box(patch_type set_type);
|
||||||
|
|
||||||
|
void update_validator(int index, QComboBox* combo_box, QLineEdit* line_edit);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void show_table_menu(const QPoint& pos);
|
void show_table_menu(const QPoint& pos);
|
||||||
void validate();
|
void validate();
|
||||||
|
@ -166,7 +166,7 @@ rsx_debugger::rsx_debugger(std::shared_ptr<gui_settings> gui_settings, QWidget*
|
|||||||
tex_idx_line->setMaxLength(18);
|
tex_idx_line->setMaxLength(18);
|
||||||
tex_idx_line->setFixedWidth(75);
|
tex_idx_line->setFixedWidth(75);
|
||||||
tex_idx_line->setFocus();
|
tex_idx_line->setFocus();
|
||||||
tex_idx_line->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,8}$")));
|
tex_idx_line->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,8}$"), this));
|
||||||
|
|
||||||
QLineEdit* tex_fmt_override_line = new QLineEdit(this);
|
QLineEdit* tex_fmt_override_line = new QLineEdit(this);
|
||||||
tex_fmt_override_line->setPlaceholderText("00");
|
tex_fmt_override_line->setPlaceholderText("00");
|
||||||
@ -174,7 +174,7 @@ rsx_debugger::rsx_debugger(std::shared_ptr<gui_settings> gui_settings, QWidget*
|
|||||||
tex_fmt_override_line->setMaxLength(18);
|
tex_fmt_override_line->setMaxLength(18);
|
||||||
tex_fmt_override_line->setFixedWidth(75);
|
tex_fmt_override_line->setFixedWidth(75);
|
||||||
tex_fmt_override_line->setFocus();
|
tex_fmt_override_line->setFocus();
|
||||||
tex_fmt_override_line->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,2}$")));
|
tex_fmt_override_line->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,2}$"), this));
|
||||||
|
|
||||||
hbox_idx_line->addWidget(tex_idx_line);
|
hbox_idx_line->addWidget(tex_idx_line);
|
||||||
hbox_idx_line->addWidget(tex_fmt_override_line);
|
hbox_idx_line->addWidget(tex_fmt_override_line);
|
||||||
|
@ -33,13 +33,13 @@ system_cmd_dialog::system_cmd_dialog(QWidget* parent)
|
|||||||
m_value_input = new QLineEdit();
|
m_value_input = new QLineEdit();
|
||||||
m_value_input->setFont(mono);
|
m_value_input->setFont(mono);
|
||||||
m_value_input->setMaxLength(18);
|
m_value_input->setMaxLength(18);
|
||||||
m_value_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,8}$")));
|
m_value_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,8}$"), this));
|
||||||
m_value_input->setPlaceholderText(QString("0x%1").arg(0, 16, 16, QChar('0')));
|
m_value_input->setPlaceholderText(QString("0x%1").arg(0, 16, 16, QChar('0')));
|
||||||
|
|
||||||
m_custom_command_input = new QLineEdit();
|
m_custom_command_input = new QLineEdit();
|
||||||
m_custom_command_input->setFont(mono);
|
m_custom_command_input->setFont(mono);
|
||||||
m_custom_command_input->setMaxLength(18);
|
m_custom_command_input->setMaxLength(18);
|
||||||
m_custom_command_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,8}$")));
|
m_custom_command_input->setValidator(new QRegularExpressionValidator(QRegularExpression("^(0[xX])?0*[a-fA-F0-9]{0,8}$"), this));
|
||||||
m_custom_command_input->setPlaceholderText(QString("0x%1").arg(0, 16, 16, QChar('0')));
|
m_custom_command_input->setPlaceholderText(QString("0x%1").arg(0, 16, 16, QChar('0')));
|
||||||
|
|
||||||
m_command_box = new QComboBox();
|
m_command_box = new QComboBox();
|
||||||
|
@ -58,12 +58,12 @@ vfs_dialog_usb_input::vfs_dialog_usb_input(const QString& name, const cfg::devic
|
|||||||
|
|
||||||
m_vid_edit = new QLineEdit;
|
m_vid_edit = new QLineEdit;
|
||||||
m_vid_edit->setMaxLength(4);
|
m_vid_edit->setMaxLength(4);
|
||||||
m_vid_edit->setValidator(new QRegularExpressionValidator(QRegularExpression("^[a-fA-F0-9]*$"))); // HEX only
|
m_vid_edit->setValidator(new QRegularExpressionValidator(QRegularExpression("^[a-fA-F0-9]*$"), this)); // HEX only
|
||||||
m_vid_edit->setText(QString::fromStdString(info->vid));
|
m_vid_edit->setText(QString::fromStdString(info->vid));
|
||||||
|
|
||||||
m_pid_edit = new QLineEdit;
|
m_pid_edit = new QLineEdit;
|
||||||
m_pid_edit->setMaxLength(4);
|
m_pid_edit->setMaxLength(4);
|
||||||
m_pid_edit->setValidator(new QRegularExpressionValidator(QRegularExpression("^[a-fA-F0-9]*$"))); // HEX only
|
m_pid_edit->setValidator(new QRegularExpressionValidator(QRegularExpression("^[a-fA-F0-9]*$"), this)); // HEX only
|
||||||
m_pid_edit->setText(QString::fromStdString(info->pid));
|
m_pid_edit->setText(QString::fromStdString(info->pid));
|
||||||
|
|
||||||
m_serial_edit = new QLineEdit;
|
m_serial_edit = new QLineEdit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user