Fix minor UI issues with blob editing

By default, use the overwrite mode in the hex edit widget. This way text
and hex editor start in the same mode, making it less confusing to press
the INS key to change the mode.

When editing the data using the hex editor also update the text editor.
This commit is contained in:
Martin Kleusberg
2013-03-17 12:39:17 +01:00
parent a8af5a7c04
commit 67c141c192
2 changed files with 11 additions and 1 deletions

View File

@@ -15,6 +15,8 @@ EditDialog::EditDialog(QWidget* parent)
QHBoxLayout* hexLayout = new QHBoxLayout(ui->editorBinary);
hexEdit = new QHexEdit(this);
hexLayout->addWidget(hexEdit);
hexEdit->setOverwriteMode(false);
connect(hexEdit, SIGNAL(dataChanged()), this, SLOT(hexDataChanged()));
QShortcut* ins = new QShortcut(QKeySequence(Qt::Key_Insert), this);
connect(ins, SIGNAL(activated()), this, SLOT(toggleOverwriteMode()));
@@ -112,9 +114,16 @@ void EditDialog::accept()
void EditDialog::editTextChanged()
{
if(ui->editorText->hasFocus())
{
hexEdit->setData(ui->editorText->toPlainText().toUtf8());
checkDataType();
}
}
checkDataType();
void EditDialog::hexDataChanged()
{
// Update the text editor accordingly
ui->editorText->setPlainText(hexEdit->data());
}
void EditDialog::checkDataType()

View File

@@ -33,6 +33,7 @@ private slots:
virtual void clearData();
virtual void accept();
virtual void editTextChanged();
virtual void hexDataChanged();
virtual void checkDataType();
virtual void toggleOverwriteMode();