System shortcuts crash the Editor when Global Preferences are open (#6994)

* Changes to the keyPressEvent override of the Editor Preferences Dialog to prevent infinite loops on focus switches.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Renaming function to clarify its purpose.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>
This commit is contained in:
Danilo Aimini
2022-01-19 09:52:27 -08:00
committed by GitHub
parent 542d652776
commit a63ea12a1f
2 changed files with 13 additions and 11 deletions
+12 -10
View File
@@ -112,29 +112,31 @@ void EditorPreferencesDialog::showEvent(QShowEvent* event)
QDialog::showEvent(event);
}
void WidgetHandleKeyPressEvent(QWidget* widget, QKeyEvent* event)
bool WidgetConsumesKeyPressEvent(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.
// editing of that field has finished and then doesn't propagate it.
if (event->key() != Qt::Key::Key_Enter && event->key() != Qt::Key::Key_Return)
{
QApplication::sendEvent(widget, event);
return false;
}
else
if (QWidget* editWidget = QApplication::focusWidget())
{
if (QWidget* editWidget = QApplication::focusWidget())
{
editWidget->clearFocus();
}
editWidget->clearFocus();
}
}
return true;
}
void EditorPreferencesDialog::keyPressEvent(QKeyEvent* event)
{
WidgetHandleKeyPressEvent(this, event);
if (!WidgetConsumesKeyPressEvent(event))
{
QDialog::keyPressEvent(event);
}
}
void EditorPreferencesDialog::OnTreeCurrentItemChanged()