Allow plugins to add more than one action to the context menu

Fixes #1936472 [Enhacement Request: plugins in context menu of tag browser](https://bugs.launchpad.net/calibre/+bug/1936472)
This commit is contained in:
Kovid Goyal 2021-07-18 06:31:21 +05:30
parent 5f78eaaea5
commit 5e9798fe9e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 5 deletions

View File

@ -353,10 +353,12 @@ class InterfaceAction(QObject):
'''
Called when displaying the context menu in the Tag browser. ``index`` is
the QModelIndex that points to the Tag browser item that was right clicked.
Test it for validitiy with index.valid() and get the underlying TagTreeItem
object with index.data(Qt.ItemDataRole.UserRole)
Test it for validity with index.valid() and get the underlying TagTreeItem
object with index.data(Qt.ItemDataRole.UserRole). This method must yield one
or more action objects that will be added to the context menu.
'''
pass
if False:
yield QAction()
def shutting_down(self):
'''

View File

@ -1004,8 +1004,7 @@ class TagsView(QTreeView): # {{{
first = True
for ac in get_gui().iactions.values():
try:
context_action = ac.tag_browser_context_action(index)
if context_action is not None:
for context_action in ac.tag_browser_context_action(index):
if first:
self.context_menu.addSeparator()
first = False