mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Document the API for plugins to add actions to the tag browser context menu
This commit is contained in:
parent
88bbc4fa2d
commit
5f78eaaea5
@ -39,8 +39,8 @@ class InterfaceAction(QObject):
|
||||
priority takes precedence.
|
||||
|
||||
Sub-classes should implement the :meth:`genesis`, :meth:`library_changed`,
|
||||
:meth:`location_selected` :meth:`shutting_down`
|
||||
and :meth:`initialization_complete` methods.
|
||||
:meth:`location_selected`, :meth:`shutting_down`,
|
||||
:meth:`initialization_complete` and :meth:`tag_browser_context_action` methods.
|
||||
|
||||
Once initialized, this plugin has access to the main calibre GUI via the
|
||||
:attr:`gui` member. You can access other plugins by name, for example::
|
||||
@ -349,6 +349,15 @@ class InterfaceAction(QObject):
|
||||
'''
|
||||
pass
|
||||
|
||||
def tag_browser_context_action(self, index):
|
||||
'''
|
||||
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)
|
||||
'''
|
||||
pass
|
||||
|
||||
def shutting_down(self):
|
||||
'''
|
||||
Called once per plugin when the main GUI is in the process of shutting
|
||||
|
@ -1004,13 +1004,12 @@ class TagsView(QTreeView): # {{{
|
||||
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)
|
||||
context_action = ac.tag_browser_context_action(index)
|
||||
if context_action is not None:
|
||||
if first:
|
||||
self.context_menu.addSeparator()
|
||||
first = False
|
||||
self.context_menu.addAction(context_action)
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
Loading…
x
Reference in New Issue
Block a user