better UX for using fulltext search"

This commit is contained in:
billypom on debian 2025-04-25 18:41:14 -04:00
parent b55b105e05
commit f7a7d1e43d
2 changed files with 14 additions and 2 deletions

View File

@ -18,12 +18,20 @@ class SearchLineEdit(QLineEdit):
super().__init__(parent) super().__init__(parent)
self.setVisible(False) self.setVisible(False)
def toggle_visibility(self): def toggle_visibility(self) -> bool:
"""
Returns true if visible
false if hidden
This is used to bring focus back to the music table after toggling visibility
"""
if self.isHidden(): if self.isHidden():
self.setHidden(False) self.setHidden(False)
return True
else: else:
self.setHidden(True) self.setHidden(True)
self.setText(None) self.setText(None)
return False
# def toggle_visibility(self): # def toggle_visibility(self):
# if self.is_hidden: # if self.is_hidden:

View File

@ -491,7 +491,11 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
def handle_search_box(self): def handle_search_box(self):
"""show or hide the searchbox""" """show or hide the searchbox"""
self.lineEditSearch.toggle_visibility() visible = self.lineEditSearch.toggle_visibility()
if visible:
self.lineEditSearch.setFocus()
else:
self.tableView.setFocus()
def handle_search_box_text(self, text: str): def handle_search_box_text(self, text: str):
"""when text changes, update the music table thingie""" """when text changes, update the music table thingie"""