Skip to content

Commit

Permalink
WSearchLineEdit: fully enable controllers to scroll previous search q…
Browse files Browse the repository at this point in the history
…ueries

with [Library],MoveVertical, ..MoveDown & MoveUp controls.
  • Loading branch information
ronso0 committed Oct 15, 2020
1 parent 407ae68 commit 118f4e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,19 +569,27 @@ void LibraryControl::emitKeyEvent(QKeyEvent&& event) {
VERIFY_OR_DEBUG_ASSERT(m_pLibraryWidget) {
return;
}
VERIFY_OR_DEBUG_ASSERT(m_pSearchbox) {
return;
}
if (!QApplication::focusWindow()) {
qDebug() << "Mixxx window is not focused, don't send key events";
return;
}

bool keyIsTab = event.key() == static_cast<int>(Qt::Key_Tab);
bool keyIsUpDown = event.key() == static_cast<int>(Qt::Key_Up) ||
event.key() == static_cast<int>(Qt::Key_Down);

// If the main window has focus, any widget can receive Tab.
// Other keys should be sent to library widgets only to not
// accidentally alter spinboxes etc.
// If the searchbox has focus allow only Up/Down to select previous queries.
if (!keyIsTab && !m_pSidebarWidget->hasFocus()
&& !m_pLibraryWidget->getActiveView()->hasFocus()) {
setLibraryFocus();
if (keyIsUpDown && !m_pSearchbox->hasFocus()) {
setLibraryFocus();
}
}
if (keyIsTab && !QApplication::focusWidget()){
setLibraryFocus();
Expand Down

0 comments on commit 118f4e5

Please sign in to comment.