diff --git a/src/dialogs/EditInstructionDialog.cpp b/src/dialogs/EditInstructionDialog.cpp index 58405903..41393ece 100644 --- a/src/dialogs/EditInstructionDialog.cpp +++ b/src/dialogs/EditInstructionDialog.cpp @@ -10,7 +10,7 @@ EditInstructionDialog::EditInstructionDialog(QWidget *parent, bool isEditingByte ui->setupUi(this); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); - ui->lineEdit->installEventFilter(this); + connect(ui->lineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(updatePreview(const QString &))); } EditInstructionDialog::~EditInstructionDialog() {} @@ -51,22 +51,3 @@ void EditInstructionDialog::updatePreview(const QString &input) ui->instructionLabel->setText(result); } } - -bool EditInstructionDialog::eventFilter(QObject *obj, QEvent *event) -{ - Q_UNUSED(obj); - - if (event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = static_cast (event); - - // 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()); - } - } - - return false; -} \ No newline at end of file diff --git a/src/dialogs/EditInstructionDialog.h b/src/dialogs/EditInstructionDialog.h index 8a082961..4a5ead87 100644 --- a/src/dialogs/EditInstructionDialog.h +++ b/src/dialogs/EditInstructionDialog.h @@ -20,18 +20,16 @@ public: QString getInstruction(); void setInstruction(const QString &instruction); - void updatePreview(const QString &input); - private slots: void on_buttonBox_accepted(); void on_buttonBox_rejected(); + void updatePreview(const QString &input); + private: std::unique_ptr ui; bool isEditingBytes; // true if editing intruction **bytes**; false if editing instruction **text** - - bool eventFilter(QObject *obj, QEvent *event); }; #endif // EDITINSTRUCTIONDIALOG_H