diff --git a/components/SearchLineEdit.py b/components/SearchLineEdit.py index 434b24b..4bd9e9b 100644 --- a/components/SearchLineEdit.py +++ b/components/SearchLineEdit.py @@ -18,12 +18,20 @@ class SearchLineEdit(QLineEdit): super().__init__(parent) 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(): self.setHidden(False) + return True else: self.setHidden(True) self.setText(None) + return False # def toggle_visibility(self): # if self.is_hidden: diff --git a/main.py b/main.py index 39c466d..770d527 100644 --- a/main.py +++ b/main.py @@ -491,7 +491,11 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow): def handle_search_box(self): """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): """when text changes, update the music table thingie"""