Focus issue in editor settings menu #3921 (#6296)

* Changes to fix DCO

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Moved the keyEvent to a helper function for ease of testing

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>

* Split definition and declaration of WidgetHandleKeyPressEvent

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>
This commit is contained in:
John Jones-Steele
2021-12-10 22:34:41 +00:00
committed by GitHub
parent 5fd68cf1c2
commit 3ae6b601a2
2 changed files with 28 additions and 0 deletions
+25
View File
@@ -112,6 +112,31 @@ void EditorPreferencesDialog::showEvent(QShowEvent* event)
QDialog::showEvent(event);
}
void WidgetHandleKeyPressEvent(QWidget* widget, QKeyEvent* event)
{
// If the enter key is pressed during any text input, the dialog box will close
// making it inconvenient to do multiple edits. This routine captures the
// Key_Enter or Key_Return and clears the focus to give a visible cue that
// editing of that field has finished and then doesn't propogate it.
if (event->key() != Qt::Key::Key_Enter && event->key() != Qt::Key::Key_Return)
{
QApplication::sendEvent(widget, event);
}
else
{
if (QWidget* editWidget = QApplication::focusWidget())
{
editWidget->clearFocus();
}
}
}
void EditorPreferencesDialog::keyPressEvent(QKeyEvent* event)
{
WidgetHandleKeyPressEvent(this, event);
}
void EditorPreferencesDialog::OnTreeCurrentItemChanged()
{
QTreeWidgetItem* currentItem = ui->pageTree->currentItem();