mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 11:26:11 +00:00
Fix instruction preview dialog (#714)
This commit is contained in:
parent
f6955e4eab
commit
6fe3681871
@ -10,7 +10,7 @@ EditInstructionDialog::EditInstructionDialog(QWidget *parent, bool isEditingByte
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||||
|
|
||||||
ui->lineEdit->installEventFilter(this);
|
connect(ui->lineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(updatePreview(const QString &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
EditInstructionDialog::~EditInstructionDialog() {}
|
EditInstructionDialog::~EditInstructionDialog() {}
|
||||||
@ -51,22 +51,3 @@ void EditInstructionDialog::updatePreview(const QString &input)
|
|||||||
ui->instructionLabel->setText(result);
|
ui->instructionLabel->setText(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditInstructionDialog::eventFilter(QObject *obj, QEvent *event)
|
|
||||||
{
|
|
||||||
Q_UNUSED(obj);
|
|
||||||
|
|
||||||
if (event->type() == QEvent::KeyPress) {
|
|
||||||
QKeyEvent *keyEvent = static_cast <QKeyEvent *>(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;
|
|
||||||
}
|
|
@ -20,18 +20,16 @@ public:
|
|||||||
QString getInstruction();
|
QString getInstruction();
|
||||||
void setInstruction(const QString &instruction);
|
void setInstruction(const QString &instruction);
|
||||||
|
|
||||||
void updatePreview(const QString &input);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_buttonBox_accepted();
|
void on_buttonBox_accepted();
|
||||||
|
|
||||||
void on_buttonBox_rejected();
|
void on_buttonBox_rejected();
|
||||||
|
|
||||||
|
void updatePreview(const QString &input);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::EditInstructionDialog> ui;
|
std::unique_ptr<Ui::EditInstructionDialog> ui;
|
||||||
bool isEditingBytes; // true if editing intruction **bytes**; false if editing instruction **text**
|
bool isEditingBytes; // true if editing intruction **bytes**; false if editing instruction **text**
|
||||||
|
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDITINSTRUCTIONDIALOG_H
|
#endif // EDITINSTRUCTIONDIALOG_H
|
||||||
|
Loading…
Reference in New Issue
Block a user