diff --git a/src/library/autodj/dlgautodj.cpp b/src/library/autodj/dlgautodj.cpp index adfe89852ac3..3be441dc09f1 100644 --- a/src/library/autodj/dlgautodj.cpp +++ b/src/library/autodj/dlgautodj.cpp @@ -163,12 +163,7 @@ DlgAutoDJ::DlgAutoDJ(WLibrary* parent, // work around QLineEdit being protected QLineEdit* lineEditTransition(spinBoxTransition->findChild()); lineEditTransition->setFocusPolicy(Qt::ClickFocus); - // Catch any Return keypress to pass focus to tracks table - connect(lineEditTransition, - &QLineEdit::returnPressed, - this, - // Move focus to tracks table to immediately allow keyboard shortcuts again. - &DlgAutoDJ::setFocus); + installEventFilter(lineEditTransition); connect(spinBoxTransition, QOverload::of(&QSpinBox::valueChanged), @@ -386,6 +381,18 @@ void DlgAutoDJ::setFocus() { m_pTrackTableView->setFocus(); } +void DlgAutoDJ::keyPressEvent(QKeyEvent* pEvent) { + // Return, Enter and Escape key move focus to the AutoDJ queue to immediately + // allow keyboard shortcuts again. + if (pEvent->key() == Qt::Key_Return || + pEvent->key() == Qt::Key_Enter || + pEvent->key() == Qt::Key_Escape) { + setFocus(); + return; + } + return QWidget::keyPressEvent(pEvent); +} + void DlgAutoDJ::saveCurrentViewState() { m_pTrackTableView->saveCurrentViewState(); } diff --git a/src/library/autodj/dlgautodj.h b/src/library/autodj/dlgautodj.h index d0976f2d3c77..163146e6bc88 100644 --- a/src/library/autodj/dlgautodj.h +++ b/src/library/autodj/dlgautodj.h @@ -59,6 +59,7 @@ class DlgAutoDJ : public QWidget, public Ui::DlgAutoDJ, public LibraryView { void setupActionButton(QPushButton* pButton, void (DlgAutoDJ::*pSlot)(bool), const QString& fallbackText); + void keyPressEvent(QKeyEvent* pEvent) override; const UserSettingsPointer m_pConfig; diff --git a/src/widget/wbeatspinbox.cpp b/src/widget/wbeatspinbox.cpp index ded403b4a596..81e16d70845d 100644 --- a/src/widget/wbeatspinbox.cpp +++ b/src/widget/wbeatspinbox.cpp @@ -297,12 +297,15 @@ bool WBeatSpinBox::event(QEvent* pEvent) { } void WBeatSpinBox::keyPressEvent(QKeyEvent* pEvent) { - // Return key applies current value and sends a Shift+Tab event in order - // to focus a library widget. In official skins this would be the tracks table. - if (pEvent->key() == Qt::Key_Return) { + // Return & Enter keys apply current value. + // Return, Enter and Escape send a Shift+Tab event in order to move focus + // to a library widget. In official skins this would be the tracks table. + if (pEvent->key() == Qt::Key_Return || + pEvent->key() == Qt::Key_Enter || + pEvent->key() == Qt::Key_Escape) { QDoubleSpinBox::keyPressEvent(pEvent); - QKeyEvent returnKeyEvent = QKeyEvent{QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier}; - QApplication::sendEvent(this, &returnKeyEvent); + QKeyEvent shiftTabKeyEvent = QKeyEvent{QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier}; + QApplication::sendEvent(this, &shiftTabKeyEvent); return; } return QDoubleSpinBox::keyPressEvent(pEvent);