Added Quick Select keybind on tag search

Implemented that if return was to be pressed while only 1 tag search result was left that it's selection state is toggled.
dev
peery 3 years ago
parent 6eb55bb3dc
commit cba7484864

@ -421,7 +421,7 @@ class Window(QtWidgets.QMainWindow):
""" """
return self.__main.db_connection.search_fuzzy_tag(name, all_if_empty=True) return self.__main.db_connection.search_fuzzy_tag(name, all_if_empty=True)
def set_search_result_list(self, tags: list): def set_tag_search_result_list(self, tags: list):
""" """
Set the tags in the search result list to tags Set the tags in the search result list to tags
:param tags: :param tags:
@ -434,6 +434,7 @@ class Window(QtWidgets.QMainWindow):
flags = Qt.ItemIsEnabled flags = Qt.ItemIsEnabled
if tag not in self.curr_imply_tags+self.curr_tag_aliases and tag not in self.curr_tags: if tag not in self.curr_imply_tags+self.curr_tag_aliases and tag not in self.curr_tags:
# new tag and not implied yet
item.setData(Qt.Unchecked, Qt.CheckStateRole) item.setData(Qt.Unchecked, Qt.CheckStateRole)
flags |= Qt.ItemIsUserCheckable flags |= Qt.ItemIsUserCheckable
if self.curr_tags is not None and tag in (self.curr_tags+self.curr_imply_tags+self.curr_tag_aliases): if self.curr_tags is not None and tag in (self.curr_tags+self.curr_imply_tags+self.curr_tag_aliases):
@ -655,6 +656,21 @@ class Window(QtWidgets.QMainWindow):
self.__pixmap.setPaused(True) self.__pixmap.setPaused(True)
self.set_temporary_status_message("Paused the Video!", 3000) self.set_temporary_status_message("Paused the Video!", 3000)
elif QtWidgets.QApplication.focusWidget() == self.ui.tag_search_bar: # quick select for the search bar
if self.ui.search_result_list.model().rowCount() == 1: # only 1 search result left
model_index = self.ui.search_result_list.model().index(0, 0)
item_data = self.ui.search_result_list.model().itemData(model_index)
if item_data[0] not in self.curr_tags: # add/remove new selected tag to the lists
self.curr_tags.append(item_data[0])
else:
self.curr_tags.remove(item_data[0])
self.set_tag_list(self.curr_tags) # update relevant lists
self.set_tag_search_result_list([item_data[0]])
print(item_data)
def on_movie_player_state_changed(self, state: int): def on_movie_player_state_changed(self, state: int):
self.__image_resize() self.__image_resize()
if QtMultimedia.QMediaPlayer.StoppedState == state: # player stopped if QtMultimedia.QMediaPlayer.StoppedState == state: # player stopped
@ -939,7 +955,7 @@ class Window(QtWidgets.QMainWindow):
for tag_name, tag_desc, tag_category in tags: for tag_name, tag_desc, tag_category in tags:
result.append(tag_name) result.append(tag_name)
self.set_search_result_list(result) self.set_tag_search_result_list(result)
def on_category_creation_clicked(self): def on_category_creation_clicked(self):
dialog = CategoryModDialog(self, delete_category=False) dialog = CategoryModDialog(self, delete_category=False)

Loading…
Cancel
Save