diff --git a/src/dialogs/EditInstructionDialog.cpp b/src/dialogs/EditInstructionDialog.cpp
index 67d61736..2fa22fe8 100644
--- a/src/dialogs/EditInstructionDialog.cpp
+++ b/src/dialogs/EditInstructionDialog.cpp
@@ -1,5 +1,6 @@
#include "EditInstructionDialog.h"
#include "ui_EditInstructionDialog.h"
+#include "Cutter.h"
EditInstructionDialog::EditInstructionDialog(QWidget *parent) :
QDialog(parent),
@@ -32,6 +33,16 @@ QString EditInstructionDialog::getInstruction()
void EditInstructionDialog::setInstruction(const QString &instruction)
{
ui->lineEdit->setText(instruction);
+ updatePreview(instruction);
+}
+
+void EditInstructionDialog::updatePreview(const QString &hex) {
+ QString result = Core()->disassemble(hex).trimmed();
+ if (result.isEmpty() || result.contains("\n")) {
+ ui->instructionLabel->setText("Unknown Instruction");
+ } else {
+ ui->instructionLabel->setText(result);
+ }
}
bool EditInstructionDialog::eventFilter(QObject *obj, QEvent *event)
@@ -47,6 +58,14 @@ bool EditInstructionDialog::eventFilter(QObject *obj, QEvent *event)
this->accept();
return true;
}
+
+ // Update instruction preview
+ QString lineText = ui->lineEdit->text();
+ if (keyEvent -> key() == Qt::Key_Backspace) {
+ updatePreview(lineText.left(lineText.size() - 1));
+ } else {
+ updatePreview(lineText + keyEvent->text());
+ }
}
diff --git a/src/dialogs/EditInstructionDialog.h b/src/dialogs/EditInstructionDialog.h
index 1c84967f..4115a007 100644
--- a/src/dialogs/EditInstructionDialog.h
+++ b/src/dialogs/EditInstructionDialog.h
@@ -19,6 +19,8 @@ public:
QString getInstruction();
void setInstruction(const QString &instruction);
+
+ void updatePreview(const QString &hex);
private slots:
void on_buttonBox_accepted();
diff --git a/src/dialogs/EditInstructionDialog.ui b/src/dialogs/EditInstructionDialog.ui
index e1d9f848..99881dfe 100644
--- a/src/dialogs/EditInstructionDialog.ui
+++ b/src/dialogs/EditInstructionDialog.ui
@@ -13,6 +13,9 @@
Edit Instruction
+
+ false
+
2
@@ -30,13 +33,62 @@
2
-
-
-
- 0
-
+
+
-
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
-
+ -
+
+
+ 5
+
+
+ 0
+
+
-
+
+
+
+ 1000
+ 10
+
+
+
+ Qt::RightToLeft
+
+
+ Unknown Instruction
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
-