mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-21 12: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);
|
||||
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 <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();
|
||||
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::EditInstructionDialog> ui;
|
||||
bool isEditingBytes; // true if editing intruction **bytes**; false if editing instruction **text**
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
};
|
||||
|
||||
#endif // EDITINSTRUCTIONDIALOG_H
|
||||
|
Loading…
Reference in New Issue
Block a user