diff --git a/src/controllers/controlpickermenu.cpp b/src/controllers/controlpickermenu.cpp index 21e0bee951c4..9cc98777c6ab 100644 --- a/src/controllers/controlpickermenu.cpp +++ b/src/controllers/controlpickermenu.cpp @@ -402,6 +402,10 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent) tr("Move focus to right/left pane"), tr("Move focus one pane to right or left using a knob, as if pressing TAB/SHIFT+TAB keys"), m_libraryStr, libraryMenu); + addPrefixedControl("[Library]", "GoToItem", + tr("Go to the currently selected item"), + tr("Choose the currently selected item and advance forward one pane if appropriate"), + m_libraryStr, libraryMenu); addPrefixedControl("[Library]", "AutoDjAddBottom", tr("Add to Auto DJ Queue (bottom)"), tr("Append the selected track to the Auto DJ Queue"), diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index ca6e7b196656..18b74a0bc710 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -11,6 +11,7 @@ #include "control/controlpushbutton.h" #include "mixer/playermanager.h" #include "widget/wlibrarysidebar.h" +#include "widget/wtracktableview.h" #include "library/library.h" #include "library/libraryview.h" #include "util/container.h" @@ -91,9 +92,9 @@ LibraryControl::LibraryControl(Library* pLibrary) connect(m_pMoveFocusBackward.get(), SIGNAL(valueChanged(double)),this, SLOT(slotMoveFocusBackward(double))); connect(m_pMoveFocus.get(), SIGNAL(valueChanged(double)),this, SLOT(slotMoveFocus(double))); - // Control to choose the currently selected item in focussed widget (double click) - m_pChooseItem = std::make_unique(ConfigKey("[Library]", "ChooseItem")); - connect(m_pChooseItem.get(), SIGNAL(valueChanged(double)), this, SLOT(slotChooseItem(double))); + // Control to "goto" the currently selected item in focussed widget (context dependent) + m_pGoToItem = std::make_unique(ConfigKey("[Library]", "GoToItem")); + connect(m_pGoToItem.get(), SIGNAL(valueChanged(double)), this, SLOT(slotGoToItem(double))); // Auto DJ controls m_pAutoDjAddTop = std::make_unique(ConfigKey("[Library]","AutoDjAddTop")); @@ -233,7 +234,7 @@ void LibraryControl::slotLoadSelectedTrackToGroup(QString group, bool play) { } void LibraryControl::slotLoadSelectedIntoFirstStopped(double v) { - + if (v > 0) { LibraryView* activeView = m_pLibrary->getActiveView(); if (!activeView) { @@ -410,18 +411,17 @@ void LibraryControl::slotToggleSelectedSidebarItem(double v) { } } -void LibraryControl::slotChooseItem(double v) { - // XXX: Make this more generic? If Enter key is mapped correctly maybe we can use that - if (!m_pLibrary) { - return; - } - // Load current track if a LibraryView object has focus - const auto activeView = m_pLibrary->getActiveView(); - if (activeView && activeView->hasFocus()) { - return slotLoadSelectedIntoFirstStopped(v); +void LibraryControl::slotGoToItem(double v) { + if (v > 0) { + if (dynamic_cast(QApplication::focusWidget())) { + // If main pane is focused then try to load the selected track into first stopped + return slotLoadSelectedIntoFirstStopped(v); + } else { + // Otherwise we press return + tab to select current item and go to the next pane + emitKeyEvent(QKeyEvent{QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier}); + emitKeyEvent(QKeyEvent{QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier}); + } } - // Otherwise toggle the sidebar item expanded state (like a double-click) - slotToggleSelectedSidebarItem(v); } void LibraryControl::slotFontSize(double v) { diff --git a/src/library/librarycontrol.h b/src/library/librarycontrol.h index 4b3427d0bb28..e4e9d96c98b8 100644 --- a/src/library/librarycontrol.h +++ b/src/library/librarycontrol.h @@ -37,7 +37,7 @@ class LibraryControl : public QObject { public: LibraryControl(Library* pLibrary); virtual ~LibraryControl(); - + void bindSidebarWidget(WLibrarySidebar* pLibrarySidebar); private slots: @@ -55,7 +55,7 @@ class LibraryControl : public QObject { void slotMoveFocusForward(double); void slotMoveFocusBackward(double); void slotMoveFocus(double); - void slotChooseItem(double v); + void slotGoToItem(double v); // Deprecated navigation slots void slotLoadSelectedTrackToGroup(QString group, bool play); @@ -108,7 +108,7 @@ class LibraryControl : public QObject { std::unique_ptr m_pMoveFocus; // Control to choose the currently selected item in focused widget (double click) - std::unique_ptr m_pChooseItem; + std::unique_ptr m_pGoToItem; // Add to Auto-Dj Cueue std::unique_ptr m_pAutoDjAddTop;