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:
parent
67191d339c
commit
9166330618
@ -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)
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user