2018-02-12 20:12:13 +00:00
|
|
|
#include "EditInstructionDialog.h"
|
|
|
|
#include "ui_EditInstructionDialog.h"
|
2018-09-09 17:55:13 +00:00
|
|
|
#include "Cutter.h"
|
2018-02-12 20:12:13 +00:00
|
|
|
|
2018-10-23 05:06:26 +00:00
|
|
|
EditInstructionDialog::EditInstructionDialog(QWidget *parent, InstructionEditMode editMode) :
|
2018-02-12 20:12:13 +00:00
|
|
|
QDialog(parent),
|
2018-09-14 17:20:54 +00:00
|
|
|
ui(new Ui::EditInstructionDialog),
|
2018-10-23 05:06:26 +00:00
|
|
|
editMode(editMode)
|
2018-02-12 20:12:13 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
|
|
|
|
2018-09-30 20:00:53 +00:00
|
|
|
connect(ui->lineEdit, SIGNAL(textEdited(const QString &)), this,
|
|
|
|
SLOT(updatePreview(const QString &)));
|
2018-02-12 20:12:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditInstructionDialog::~EditInstructionDialog() {}
|
|
|
|
|
|
|
|
void EditInstructionDialog::on_buttonBox_accepted()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditInstructionDialog::on_buttonBox_rejected()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString EditInstructionDialog::getInstruction()
|
|
|
|
{
|
|
|
|
QString ret = ui->lineEdit->text();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditInstructionDialog::setInstruction(const QString &instruction)
|
|
|
|
{
|
|
|
|
ui->lineEdit->setText(instruction);
|
2018-09-09 17:55:13 +00:00
|
|
|
updatePreview(instruction);
|
|
|
|
}
|
|
|
|
|
2018-09-14 17:20:54 +00:00
|
|
|
void EditInstructionDialog::updatePreview(const QString &input)
|
|
|
|
{
|
|
|
|
QString result;
|
2018-10-23 05:06:26 +00:00
|
|
|
|
|
|
|
if (editMode == EDIT_NONE) {
|
|
|
|
ui->instructionLabel->setText("");
|
|
|
|
return;
|
|
|
|
} else if (editMode == EDIT_BYTES) {
|
2018-09-14 17:20:54 +00:00
|
|
|
result = Core()->disassemble(input).trimmed();
|
2018-10-23 05:06:26 +00:00
|
|
|
} else if (editMode == EDIT_TEXT) {
|
2018-09-14 17:20:54 +00:00
|
|
|
result = Core()->assemble(input).trimmed();
|
|
|
|
}
|
|
|
|
|
2018-09-09 17:55:13 +00:00
|
|
|
if (result.isEmpty() || result.contains("\n")) {
|
|
|
|
ui->instructionLabel->setText("Unknown Instruction");
|
|
|
|
} else {
|
|
|
|
ui->instructionLabel->setText(result);
|
|
|
|
}
|
2018-02-12 20:12:13 +00:00
|
|
|
}
|