mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
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
2 changed files with 9 additions and 1 deletions
|
@ -809,7 +809,9 @@ class Browser(QMainWindow):
|
||||||
c = self.card = self.mw.reviewer.card
|
c = self.card = self.mw.reviewer.card
|
||||||
nid = c and c.nid or 0
|
nid = c and c.nid or 0
|
||||||
if nid:
|
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)
|
self.focusCid(c.id)
|
||||||
else:
|
else:
|
||||||
self.model.search(self._lastSearchTxt)
|
self.model.search(self._lastSearchTxt)
|
||||||
|
|
|
@ -274,6 +274,12 @@ hooks = [
|
||||||
),
|
),
|
||||||
# Browser
|
# 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_will_show", args=["browser: aqt.browser.Browser"]),
|
||||||
Hook(
|
Hook(
|
||||||
name="browser_menus_did_init",
|
name="browser_menus_did_init",
|
||||||
|
|
Loading…
Reference in a new issue