NF: Add a hook to change the default search from reviewer

The goal here is to simplify my add-on which show a single card or the whole deck when the browser open
This commit is contained in:
Arthur Milchior 2021-01-02 19:38:57 +01:00
parent 67191d339c
commit 9166330618
2 changed files with 9 additions and 1 deletions

View File

@ -809,7 +809,9 @@ class Browser(QMainWindow):
c = self.card = self.mw.reviewer.card
nid = c and c.nid or 0
if nid:
self.model.search("nid:%d" % nid)
search = "nid:%d" % nid
search = gui_hooks.default_search(search, c)
self.model.search(search)
self.focusCid(c.id)
else:
self.model.search(self._lastSearchTxt)

View File

@ -274,6 +274,12 @@ hooks = [
),
# Browser
###################
Hook(
name="default_search",
args=["current_search: str", "c: Card"],
return_type="str",
doc="Change the default search when the card browser is opened with card `c`.",
),
Hook(name="browser_will_show", args=["browser: aqt.browser.Browser"]),
Hook(
name="browser_menus_did_init",