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

Replace the ChooseItem control with new GoToItem #12

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
4 changes: 4 additions & 0 deletions src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
30 changes: 15 additions & 15 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<ControlPushButton>(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<ControlPushButton>(ConfigKey("[Library]", "GoToItem"));
connect(m_pGoToItem.get(), SIGNAL(valueChanged(double)), this, SLOT(slotGoToItem(double)));

// Auto DJ controls
m_pAutoDjAddTop = std::make_unique<ControlPushButton>(ConfigKey("[Library]","AutoDjAddTop"));
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<WTrackTableView*>(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) {
Expand Down
6 changes: 3 additions & 3 deletions src/library/librarycontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LibraryControl : public QObject {
public:
LibraryControl(Library* pLibrary);
virtual ~LibraryControl();

void bindSidebarWidget(WLibrarySidebar* pLibrarySidebar);

private slots:
Expand All @@ -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);
Expand Down Expand Up @@ -108,7 +108,7 @@ class LibraryControl : public QObject {
std::unique_ptr<ControlObject> m_pMoveFocus;

// Control to choose the currently selected item in focused widget (double click)
std::unique_ptr<ControlObject> m_pChooseItem;
std::unique_ptr<ControlObject> m_pGoToItem;

// Add to Auto-Dj Cueue
std::unique_ptr<ControlObject> m_pAutoDjAddTop;
Expand Down