From caa3d22159b1a267905a702468753d225d90818b Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 4 Oct 2021 17:32:34 +0200 Subject: [PATCH 1/3] WBeatSpinBox: press Return to pass focus to library --- src/widget/wbeatspinbox.cpp | 13 +++++++++++++ src/widget/wbeatspinbox.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/widget/wbeatspinbox.cpp b/src/widget/wbeatspinbox.cpp index 945790e541b..ded403b4a59 100644 --- a/src/widget/wbeatspinbox.cpp +++ b/src/widget/wbeatspinbox.cpp @@ -1,5 +1,6 @@ #include "widget/wbeatspinbox.h" +#include #include #include @@ -295,6 +296,18 @@ bool WBeatSpinBox::event(QEvent* pEvent) { return QDoubleSpinBox::event(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) { + QDoubleSpinBox::keyPressEvent(pEvent); + QKeyEvent returnKeyEvent = QKeyEvent{QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier}; + QApplication::sendEvent(this, &returnKeyEvent); + return; + } + return QDoubleSpinBox::keyPressEvent(pEvent); +} + bool WBeatLineEdit::event(QEvent* pEvent) { if (pEvent->type() == QEvent::FontChange) { const QFont& fonti = font(); diff --git a/src/widget/wbeatspinbox.h b/src/widget/wbeatspinbox.h index b27eaaf60fb..bf60833a5cc 100644 --- a/src/widget/wbeatspinbox.h +++ b/src/widget/wbeatspinbox.h @@ -33,6 +33,7 @@ class WBeatSpinBox : public QDoubleSpinBox, public WBaseWidget { // for font scaling bool event(QEvent* pEvent) override; + void keyPressEvent(QKeyEvent* pEvent) override; double m_scaleFactor; }; From bad7bdcabddf983d08664339a56ca797e4269131 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Tue, 5 Oct 2021 00:50:31 +0200 Subject: [PATCH 2/3] WEffectSelector: after selecting an effect pass focus to library --- src/widget/weffectselector.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/widget/weffectselector.cpp b/src/widget/weffectselector.cpp index acea20e30ea..2accf620b9d 100644 --- a/src/widget/weffectselector.cpp +++ b/src/widget/weffectselector.cpp @@ -1,5 +1,6 @@ #include "widget/weffectselector.h" +#include #include #include "effects/effectsmanager.h" @@ -11,9 +12,11 @@ WEffectSelector::WEffectSelector(QWidget* pParent, EffectsManager* pEffectsManag WBaseWidget(this), m_pEffectsManager(pEffectsManager), m_scaleFactor(1.0) { - // Prevent this widget from getting focused to avoid - // interfering with using the library via keyboard. - setFocusPolicy(Qt::NoFocus); + // Prevent this widget from getting focused by Tab/Shift+Tab + // to avoid interfering with using the library via keyboard. + // Allow click focus though so the list can always be opened by mouse, + // see https://bugs.launchpad.net/mixxx/+bug/1902125 + setFocusPolicy(Qt::ClickFocus); } void WEffectSelector::setup(const QDomNode& node, const SkinContext& context) { @@ -37,7 +40,7 @@ void WEffectSelector::setup(const QDomNode& node, const SkinContext& context) { this, &WEffectSelector::slotEffectUpdated); connect(this, - QOverload::of(&WEffectSelector::currentIndexChanged), + QOverload::of(&WEffectSelector::activated), this, &WEffectSelector::slotEffectSelected); } else { @@ -91,6 +94,12 @@ void WEffectSelector::slotEffectSelected(int newIndex) { id); setBaseTooltip(itemData(newIndex, Qt::ToolTipRole).toString()); + // After selecting an effect send Shift+Tab to move focus to the next + // keyboard-focusable widget (tracks table in official skins) in order + // to immediately allow keyboard shortcuts again. + QKeyEvent backwardFocusKeyEvent = + QKeyEvent{QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier}; + QApplication::sendEvent(this, &backwardFocusKeyEvent); } void WEffectSelector::slotEffectUpdated() { From 2802f8225c2f02aa7395a898a91530b7f51158f4 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Tue, 5 Oct 2021 03:44:58 +0200 Subject: [PATCH 3/3] DlgAutoDJ: after configuring the transition pass focus to library --- src/library/autodj/dlgautodj.cpp | 28 +++++++++++++++++++++++----- src/library/autodj/dlgautodj.h | 1 + 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/library/autodj/dlgautodj.cpp b/src/library/autodj/dlgautodj.cpp index a116213549c..94ff6780ac9 100644 --- a/src/library/autodj/dlgautodj.cpp +++ b/src/library/autodj/dlgautodj.cpp @@ -1,5 +1,6 @@ #include "library/autodj/dlgautodj.h" +#include #include #include "library/playlisttablemodel.h" @@ -160,7 +161,13 @@ DlgAutoDJ::DlgAutoDJ(WLibrary* parent, fadeModeCombobox->setFocusPolicy(Qt::ClickFocus); spinBoxTransition->setFocusPolicy(Qt::ClickFocus); // work around QLineEdit being protected - spinBoxTransition->findChild()->setFocusPolicy(Qt::ClickFocus); + QLineEdit* lineEditTransition(spinBoxTransition->findChild()); + lineEditTransition->setFocusPolicy(Qt::ClickFocus); + // Catch any Return keypress to pass focus to tracks table + connect(lineEditTransition, + &QLineEdit::returnPressed, + this, + &DlgAutoDJ::shiftTabKeypress); connect(spinBoxTransition, QOverload::of(&QSpinBox::valueChanged), @@ -178,7 +185,7 @@ DlgAutoDJ::DlgAutoDJ(WLibrary* parent, fadeModeCombobox->setCurrentIndex( fadeModeCombobox->findData(static_cast(m_pAutoDJProcessor->getTransitionMode()))); connect(fadeModeCombobox, - QOverload::of(&QComboBox::currentIndexChanged), + QOverload::of(&QComboBox::activated), this, &DlgAutoDJ::slotTransitionModeChanged); @@ -330,9 +337,11 @@ void DlgAutoDJ::autoDJStateChanged(AutoDJProcessor::AutoDJState state) { } } -void DlgAutoDJ::slotTransitionModeChanged(int comboboxIndex) { - m_pAutoDJProcessor->setTransitionMode(static_cast( - fadeModeCombobox->itemData(comboboxIndex).toInt())); +void DlgAutoDJ::slotTransitionModeChanged(int newIndex) { + m_pAutoDJProcessor->setTransitionMode( + static_cast( + fadeModeCombobox->itemData(newIndex).toInt())); + shiftTabKeypress(); } void DlgAutoDJ::slotRepeatPlaylistChanged(int checkState) { @@ -370,3 +379,12 @@ void DlgAutoDJ::updateSelectionInfo() { bool DlgAutoDJ::hasFocus() const { return m_pTrackTableView->hasFocus(); } + +void DlgAutoDJ::shiftTabKeypress() { + // After selecting a mode or editing the transition time, send Shift+Tab + // to move focus to the next keyboard-focusable widget (tracks table in + // official skins) in order to immediately allow keyboard shortcuts again. + QKeyEvent backwardFocusKeyEvent = + QKeyEvent{QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier}; + QApplication::sendEvent(this, &backwardFocusKeyEvent); +} diff --git a/src/library/autodj/dlgautodj.h b/src/library/autodj/dlgautodj.h index de5a7499d59..1857928b657 100644 --- a/src/library/autodj/dlgautodj.h +++ b/src/library/autodj/dlgautodj.h @@ -56,6 +56,7 @@ class DlgAutoDJ : public QWidget, public Ui::DlgAutoDJ, public LibraryView { void setupActionButton(QPushButton* pButton, void (DlgAutoDJ::*pSlot)(bool), const QString& fallbackText); + void shiftTabKeypress(); const UserSettingsPointer m_pConfig;