UI: Fix enter/esc when hotkeys are disabled in focus

Fixes an issue where enter/escape/return would not work in the program
if hotkeys were disabled while in focus. No other known keys were
affected by this filter issue.
This commit is contained in:
jp9000 2021-09-20 08:16:16 -07:00
parent ef0540c0d7
commit c459e8954c

View File

@ -167,7 +167,11 @@ QObject *CreateShortcutFilter()
};
auto key_event = [&](QKeyEvent *event) {
if (!App()->HotkeysEnabledInFocus())
int key = event->key();
bool enabledInFocus = App()->HotkeysEnabledInFocus();
if (key != Qt::Key_Enter && key != Qt::Key_Escape &&
key != Qt::Key_Return && !enabledInFocus)
return true;
QDialog *dialog = qobject_cast<QDialog *>(obj);
@ -175,7 +179,7 @@ QObject *CreateShortcutFilter()
obs_key_combination_t hotkey = {0, OBS_KEY_NONE};
bool pressed = event->type() == QEvent::KeyPress;
switch (event->key()) {
switch (key) {
case Qt::Key_Shift:
case Qt::Key_Control:
case Qt::Key_Alt:
@ -195,6 +199,8 @@ QObject *CreateShortcutFilter()
case Qt::Key_Return:
if (dialog && pressed)
return false;
if (!enabledInFocus)
return true;
/* Falls through. */
default:
hotkey.key = obs_key_from_virtual_key(