def filter_actions(self, text: str): """ Filters the action lists actions """ self.actions_list.clear() for action in self.actions: if text.lower() in action.iconText().lower(): action_widget = QListWidgetItem(action.iconText()) action_widget.action = action self.actions_list.addItem(action_widget) # Select the first item self.actions_list.item(0).setSelected(True)
def setup_ui(self): # Setup the dialog self.setObjectName("ActionSearchDialog") self.resize(self.parent.width() / 3, self.parent.height() / 3) self.setWindowFlags(Qt.Popup) # The content layout = QVBoxLayout() self.action_search_edit = ActionSearchEdit() self.action_search_edit.setObjectName("action_search_edit") self.action_search_edit.setPlaceholderText("Search for action...") layout.addWidget(self.action_search_edit) self.actions_list = QListWidget() self.actions_list.setObjectName("actions_list") # Sorting # TODO: Add an option in the preferences to set how to sort the actions self.actions_list.setSortingEnabled(True) self.actions_list.sortItems(Qt.AscendingOrder) # TODO: Add option in preferences to set the number of actions displayed # Actions for action in self.actions: action_widget = QListWidgetItem(action.iconText()) action_widget.action = action self.actions_list.addItem(action_widget) # Select the first item self.actions_list.item(0).setSelected(True) layout.addWidget(self.actions_list) self.setLayout(layout) self.action_search_edit.setFocus() # Bind the signals self.bind_signals()