Skip to content

Commit

Permalink
library: add direct focus controls
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Oct 8, 2021
1 parent 40a0d2b commit 069e1f0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ LibraryControl::LibraryControl(Library* pLibrary)
m_pMoveFocusForward = std::make_unique<ControlPushButton>(ConfigKey("[Library]", "MoveFocusForward"));
m_pMoveFocusBackward = std::make_unique<ControlPushButton>(ConfigKey("[Library]", "MoveFocusBackward"));
m_pMoveFocus = std::make_unique<ControlEncoder>(ConfigKey("[Library]", "MoveFocus"), false);
m_pFocusLibraryView = std::make_unique<ControlPushButton>(
ConfigKey("[Library]", "FocusLibraryView"));
m_pFocusSidebar = std::make_unique<ControlPushButton>(ConfigKey("[Library]", "FocusSidebar"));
m_pFocusSearchbar = std::make_unique<ControlPushButton>(
ConfigKey("[Library]", "FocusSearchbar"));
connect(m_pMoveFocusForward.get(),
&ControlPushButton::valueChanged,
this,
Expand All @@ -137,6 +142,18 @@ LibraryControl::LibraryControl(Library* pLibrary)
&ControlEncoder::valueChanged,
this,
&LibraryControl::slotMoveFocus);
connect(m_pFocusLibraryView.get(),
&ControlEncoder::valueChanged,
this,
&LibraryControl::setLibraryFocus);
connect(m_pFocusSidebar.get(),
&ControlEncoder::valueChanged,
this,
&LibraryControl::setSidebarFocus);
connect(m_pFocusSearchbar.get(),
&ControlEncoder::valueChanged,
this,
&LibraryControl::setSearchbarFocus);

// Control to "goto" the currently selected item in focused widget (context dependent)
m_pGoToItem = std::make_unique<ControlPushButton>(ConfigKey("[Library]", "GoToItem"));
Expand Down Expand Up @@ -406,8 +423,6 @@ void LibraryControl::bindSearchboxWidget(WSearchLineEdit* pSearchbox) {
&LibraryControl::searchboxWidgetDeleted);
}



void LibraryControl::libraryWidgetDeleted() {
m_pLibraryWidget = nullptr;
}
Expand Down Expand Up @@ -635,6 +650,20 @@ void LibraryControl::setLibraryFocus() {
m_pLibraryWidget->getActiveView()->setFocus();
}

void LibraryControl::setSidebarFocus() {
VERIFY_OR_DEBUG_ASSERT(m_pSidebarWidget) {
return;
}
m_pSidebarWidget->setFocus();
}

void LibraryControl::setSearchbarFocus() {
VERIFY_OR_DEBUG_ASSERT(m_pSearchbox) {
return;
}
m_pSearchbox->setFocus();
}

void LibraryControl::slotSelectSidebarItem(double v) {
VERIFY_OR_DEBUG_ASSERT(m_pSidebarWidget) {
return;
Expand Down
5 changes: 5 additions & 0 deletions src/library/librarycontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class LibraryControl : public QObject {
void emitKeyEvent(QKeyEvent&& event);
// Give the keyboard focus to the main library pane
void setLibraryFocus();
void setSidebarFocus();
void setSearchbarFocus();

// Controls to navigate vertically within currently focused widget (up/down buttons)
std::unique_ptr<ControlPushButton> m_pMoveUp;
Expand All @@ -125,6 +127,9 @@ class LibraryControl : public QObject {
std::unique_ptr<ControlPushButton> m_pMoveFocusForward;
std::unique_ptr<ControlPushButton> m_pMoveFocusBackward;
std::unique_ptr<ControlEncoder> m_pMoveFocus;
std::unique_ptr<ControlPushButton> m_pFocusLibraryView;
std::unique_ptr<ControlPushButton> m_pFocusSidebar;
std::unique_ptr<ControlPushButton> m_pFocusSearchbar;

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

0 comments on commit 069e1f0

Please sign in to comment.