Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DlgAutoDJ: use setFocus() instead of keypress emulation #4490

Merged
merged 1 commit into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/library/autodj/dlgautodj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ DlgAutoDJ::DlgAutoDJ(WLibrary* parent,
connect(lineEditTransition,
&QLineEdit::returnPressed,
this,
&DlgAutoDJ::shiftTabKeypress);
// Move focus to tracks table to immediately allow keyboard shortcuts again.
&DlgAutoDJ::setFocus);

connect(spinBoxTransition,
QOverload<int>::of(&QSpinBox::valueChanged),
Expand Down Expand Up @@ -341,7 +342,8 @@ void DlgAutoDJ::slotTransitionModeChanged(int newIndex) {
m_pAutoDJProcessor->setTransitionMode(
static_cast<AutoDJProcessor::TransitionMode>(
fadeModeCombobox->itemData(newIndex).toInt()));
shiftTabKeypress();
// Move focus to tracks table to immediately allow keyboard shortcuts again.
setFocus();
}

void DlgAutoDJ::slotRepeatPlaylistChanged(int checkState) {
Expand Down Expand Up @@ -380,15 +382,6 @@ 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);
}

void DlgAutoDJ::setFocus() {
m_pTrackTableView->setFocus();
}
1 change: 0 additions & 1 deletion src/library/autodj/dlgautodj.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ 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;

Expand Down