diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2021-10-01 00:43:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-01 00:43:30 +0200 |
commit | a0b3f73531738d69d7d269303d80bb83df761d05 (patch) | |
tree | aa44a441382801935260c5cf998fa80cff4b5378 /src | |
parent | 853d4eb7e29d41c284c7a85ad141d0abd4f0fb06 (diff) | |
parent | b8fd584ff3baf0ef401a68fff59d0658cf7b7cb1 (diff) |
Merge pull request #4331 from ronso0/searchbox-controls
add [Library],clear_search
Diffstat (limited to 'src')
-rw-r--r-- | src/controllers/controlpickermenu.cpp | 7 | ||||
-rw-r--r-- | src/library/librarycontrol.cpp | 30 | ||||
-rw-r--r-- | src/library/librarycontrol.h | 1 | ||||
-rw-r--r-- | src/widget/wsearchlineedit.cpp | 3 |
4 files changed, 32 insertions, 9 deletions
diff --git a/src/controllers/controlpickermenu.cpp b/src/controllers/controlpickermenu.cpp index f72c563210..ecef8b161e 100644 --- a/src/controllers/controlpickermenu.cpp +++ b/src/controllers/controlpickermenu.cpp @@ -742,6 +742,13 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent) libraryMenu, false, m_libraryStr); + addControl("[Library]", + "clear_search", + tr("Clear search"), + tr("Clears the search query"), + libraryMenu, + false, + m_libraryStr); libraryMenu->addSeparator(); addControl("[Recording]", "toggle_recording", 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")); diff --git a/src/library/librarycontrol.h b/src/library/librarycontrol.h index c04bf9ecdd..396f841d47 100644 --- a/src/library/librarycontrol.h +++ b/src/library/librarycontrol.h @@ -147,6 +147,7 @@ class LibraryControl : public QObject { std::unique_ptr<ControlPushButton> m_pSelectHistoryNext; std::unique_ptr<ControlPushButton> m_pSelectHistoryPrev; std::unique_ptr<ControlEncoder> m_pSelectHistorySelect; + std::unique_ptr<ControlPushButton> m_pClearSearch; // Font sizes std::unique_ptr<ControlPushButton> m_pFontSizeIncrement; diff --git a/src/widget/wsearchlineedit.cpp b/src/widget/wsearchlineedit.cpp index 70791e8ae4..1fb28ce7b5 100644 --- a/src/widget/wsearchlineedit.cpp +++ b/src/widget/wsearchlineedit.cpp @@ -430,7 +430,8 @@ void WSearchLineEdit::slotSaveSearch() { void WSearchLineEdit::slotMoveSelectedHistory(int steps) { int nIndex = currentIndex() + steps; - // we wrap around to the last entry on backwards direction + // at the top we manually wrap around to the last entry. + // at the bottom wrap-around happens automatically due to invalid nIndex. if (nIndex < -1) { nIndex = count() - 1; } |