mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-24 06:56:13 +01:00
Enhacement #1936472: support plugins adding entries in the context menu of tag browser
This commit is contained in:
parent
7cccfbd20f
commit
9045c55f7f
1 changed files with 16 additions and 0 deletions
|
|
@ -999,6 +999,22 @@ def add_node_tree(tree_dict, m, path):
|
|||
_("Collapse {0}").format(p[0]), partial(self.collapse_node, p[1]))
|
||||
m.addAction(self.minus_icon, _('Collapse all'), self.collapseAll)
|
||||
|
||||
# Ask plugins if they have any actions to add to the context menu
|
||||
from calibre.gui2.ui import get_gui
|
||||
first = True
|
||||
for ac in get_gui().iactions.values():
|
||||
try:
|
||||
if hasattr(ac, 'tag_browser_context_action'):
|
||||
context_action = ac.tag_browser_context_action(index)
|
||||
if context_action:
|
||||
if first:
|
||||
self.context_menu.addSeparator()
|
||||
first = False
|
||||
self.context_menu.addAction(context_action)
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if not self.context_menu.isEmpty():
|
||||
self.context_menu.popup(self.mapToGlobal(point))
|
||||
return True
|
||||
|
|
|
|||
Loading…
Reference in a new issue