diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 3d1846814..79d88e832 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -75,7 +75,6 @@ Meredith Derecho Daniel Wallgren Kerrick Staley Maksim Abramchuk -Mateus Etto Benjamin Kulnik Shaun Ren Ryan Greenblatt @@ -105,6 +104,7 @@ wisherhxl dobefore <1432338032@qq.com> Bart Louwers Sam Penny +Mateus Etto ******************** diff --git a/qt/aqt/overview.py b/qt/aqt/overview.py index 442af6d68..8d79c0034 100644 --- a/qt/aqt/overview.py +++ b/qt/aqt/overview.py @@ -286,6 +286,12 @@ class Overview: if self.mw.col.sched.have_buried(): links.append(["U", "unbury", tr.studying_unbury()]) links.append(["", "description", tr.scheduling_description()]) + link_handler = gui_hooks.overview_will_render_bottom( + self._linkHandler, + links, + ) + if not callable(link_handler): + link_handler = self._linkHandler buf = "" for b in links: if b[0]: @@ -295,7 +301,9 @@ class Overview: b ) self.bottom.draw( - buf=buf, link_handler=self._linkHandler, web_context=OverviewBottomBar(self) + buf=buf, + link_handler=link_handler, + web_context=OverviewBottomBar(self), ) # Studying more diff --git a/qt/tools/genhooks_gui.py b/qt/tools/genhooks_gui.py index 8566b8992..90ff794bd 100644 --- a/qt/tools/genhooks_gui.py +++ b/qt/tools/genhooks_gui.py @@ -65,6 +65,34 @@ hooks = [ content.table += "\n
my html
" """, ), + Hook( + name="overview_will_render_bottom", + args=[ + "link_handler: Callable[[str], bool]", + "links: list[list[str]]", + ], + return_type="Callable[[str], bool]", + doc="""Allows adding buttons to the Overview bottom bar. + + Append a list of strings to 'links' argument to add new buttons. + - The first value is the shortcut to appear in the tooltip. + - The second value is the url to be triggered. + - The third value is the text of the new button. + + Extend the callable 'link_handler' to handle new urls. This callable + accepts one argument: the triggered url. + Make a check of the triggered url, call any functions related to + that trigger, and return the new link_handler. + + Example: + links.append(['H', 'hello', 'Click me!']) + def custom_link_handler(url): + if url == 'hello': + print('Hello World!') + return link_handler(url=url) + return custom_link_handler + """, + ), Hook( name="reviewer_did_show_question", args=["card: Card"],