diff options
author | ronso0 <ronso0@mixxx.org> | 2021-09-28 02:10:17 +0200 |
---|---|---|
committer | ronso0 <ronso0@mixxx.org> | 2021-09-30 23:35:43 +0200 |
commit | 0fe1e3d8291f0b2f6e998b5a9b03bafb7754e13a (patch) | |
tree | 7c42a41ab47eb526a50c6a722b07d277345ffaab /src/library/librarycontrol.cpp | |
parent | 3926fde35a0c5932fd15bb98c150a4c58dc36d92 (diff) |
Library: add control to clear the search, correct comments
Co-authored-by: daschuer <daschuer@mixxx.org>
Diffstat (limited to 'src/library/librarycontrol.cpp')
-rw-r--r-- | src/library/librarycontrol.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index 8dc8e82856..630fe34d9e 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -213,13 +213,9 @@ LibraryControl::LibraryControl(Library* pLibrary) this, &LibraryControl::slotTrackColorNext); - // Control to navigate between widgets (tab/shit+tab button) + // Controls to select saved searchbox queries and to clear the searchbox m_pSelectHistoryNext = std::make_unique<ControlPushButton>( ConfigKey("[Library]", "search_history_next")); - m_pSelectHistoryPrev = std::make_unique<ControlPushButton>( - ConfigKey("[Library]", "search_history_prev")); - m_pSelectHistorySelect = std::make_unique<ControlEncoder>( - ConfigKey("[Library]", "search_history_selector"), false); connect(m_pSelectHistoryNext.get(), &ControlPushButton::valueChanged, this, @@ -227,10 +223,12 @@ LibraryControl::LibraryControl(Library* pLibrary) VERIFY_OR_DEBUG_ASSERT(m_pSearchbox) { return; } - if (value >= 1.0) { + if (value > 0.0) { m_pSearchbox->slotMoveSelectedHistory(1); } }); + m_pSelectHistoryPrev = std::make_unique<ControlPushButton>( + ConfigKey("[Library]", "search_history_prev")); connect(m_pSelectHistoryPrev.get(), &ControlPushButton::valueChanged, this, @@ -238,10 +236,12 @@ LibraryControl::LibraryControl(Library* pLibrary) VERIFY_OR_DEBUG_ASSERT(m_pSearchbox) { return; } - if (value >= 1.0) { + if (value > 0.0) { m_pSearchbox->slotMoveSelectedHistory(-1); } }); + m_pSelectHistorySelect = std::make_unique<ControlEncoder>( + ConfigKey("[Library]", "search_history_selector"), false); connect(m_pSelectHistorySelect.get(), &ControlEncoder::valueChanged, this, @@ -249,10 +249,24 @@ LibraryControl::LibraryControl(Library* pLibrary) VERIFY_OR_DEBUG_ASSERT(m_pSearchbox) { return; } - if (steps >= 1.0 || steps <= -1.0) { + int iSteps = static_cast<int>(steps); + if (iSteps) { m_pSearchbox->slotMoveSelectedHistory(static_cast<int>(steps)); } }); + m_pClearSearch = std::make_unique<ControlPushButton>( + ConfigKey("[Library]", "clear_search")); + connect(m_pClearSearch.get(), + &ControlPushButton::valueChanged, + this, + [this](double value) { + VERIFY_OR_DEBUG_ASSERT(m_pSearchbox) { + return; + } + if (value > 0.0) { + m_pSearchbox->slotClearSearch(); + } + }); /// Deprecated controls m_pSelectNextTrack = std::make_unique<ControlPushButton>(ConfigKey("[Playlist]", "SelectNextTrack")); |