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.
|
priority takes precedence.
|
||||||
|
|
||||||
Sub-classes should implement the :meth:`genesis`, :meth:`library_changed`,
|
Sub-classes should implement the :meth:`genesis`, :meth:`library_changed`,
|
||||||
:meth:`location_selected` :meth:`shutting_down`
|
:meth:`location_selected`, :meth:`shutting_down`,
|
||||||
and :meth:`initialization_complete` methods.
|
:meth:`initialization_complete` and :meth:`tag_browser_context_action` methods.
|
||||||
|
|
||||||
Once initialized, this plugin has access to the main calibre GUI via the
|
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::
|
:attr:`gui` member. You can access other plugins by name, for example::
|
||||||
@ -349,6 +349,15 @@ class InterfaceAction(QObject):
|
|||||||
'''
|
'''
|
||||||
pass
|
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):
|
def shutting_down(self):
|
||||||
'''
|
'''
|
||||||
Called once per plugin when the main GUI is in the process of shutting
|
Called once per plugin when the main GUI is in the process of shutting
|
||||||
|
@ -1004,9 +1004,8 @@ class TagsView(QTreeView): # {{{
|
|||||||
first = True
|
first = True
|
||||||
for ac in get_gui().iactions.values():
|
for ac in get_gui().iactions.values():
|
||||||
try:
|
try:
|
||||||
if hasattr(ac, 'tag_browser_context_action'):
|
|
||||||
context_action = ac.tag_browser_context_action(index)
|
context_action = ac.tag_browser_context_action(index)
|
||||||
if context_action:
|
if context_action is not None:
|
||||||
if first:
|
if first:
|
||||||
self.context_menu.addSeparator()
|
self.context_menu.addSeparator()
|
||||||
first = False
|
first = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user