diff --git a/ftl/core/browsing.ftl b/ftl/core/browsing.ftl index f7e803bff..e563cd823 100644 --- a/ftl/core/browsing.ftl +++ b/ftl/core/browsing.ftl @@ -21,6 +21,11 @@ browsing-change-note-type2 = Change Note Type... browsing-change-to = Change { $val } to: browsing-clear-unused = Clear Unused browsing-clear-unused-tags = Clear Unused Tags +browsing-confirm-saved-searches-deletion = + { $count -> + [one] Are you sure you want to delete the selected saved search? + *[other] Are you sure you want to delete the { $count } selected saved searches? + } browsing-created = Created browsing-ctrlandshiftande = Ctrl+Shift+E browsing-current-deck = Current Deck diff --git a/qt/aqt/sidebar.py b/qt/aqt/sidebar.py index 6f8e8897c..f56723953 100644 --- a/qt/aqt/sidebar.py +++ b/qt/aqt/sidebar.py @@ -353,7 +353,7 @@ class SidebarTreeView(QTreeView): ), SidebarItemType.SAVED_SEARCH: ( (tr(TR.ACTIONS_RENAME), self.rename_saved_search), - (tr(TR.ACTIONS_DELETE), self.remove_saved_search), + (tr(TR.ACTIONS_DELETE), self.remove_saved_searches), ), SidebarItemType.NOTETYPE: ((tr(TR.ACTIONS_MANAGE), self.manage_notetype),), SidebarItemType.SAVED_SEARCH_ROOT: ( @@ -1177,12 +1177,17 @@ class SidebarTreeView(QTreeView): def _set_saved_searches(self, searches: Dict[str, str]) -> None: self.col.set_config(self._saved_searches_key, searches) - def remove_saved_search(self, item: SidebarItem) -> None: - name = item.name - if not askUser(tr(TR.BROWSING_REMOVE_FROM_YOUR_SAVED_SEARCHES, val=name)): + def remove_saved_searches(self, _item: SidebarItem) -> None: + selected = self._selected_saved_searches() + if len(selected) == 1: + query = tr(TR.BROWSING_REMOVE_FROM_YOUR_SAVED_SEARCHES, val=selected[0]) + else: + query = tr(TR.BROWSING_CONFIRM_SAVED_SEARCHES_DELETION, count=len(selected)) + if not askUser(query): return conf = self._get_saved_searches() - del conf[name] + for name in selected: + del conf[name] self._set_saved_searches(conf) self.refresh() @@ -1234,3 +1239,10 @@ class SidebarTreeView(QTreeView): for item in self._selected_items() if item.item_type == SidebarItemType.DECK ] + + def _selected_saved_searches(self) -> List[str]: + return [ + item.name + for item in self._selected_items() + if item.item_type == SidebarItemType.SAVED_SEARCH + ]