Merge pull request #1254 from RumovZ/sidebar-menu-hook
Add hook "browser_sidebar_will_show_context_menu"
This commit is contained in:
commit
7e358707e5
@ -829,6 +829,7 @@ class SidebarTreeView(QTreeView):
|
|||||||
self._maybe_add_rename_action(menu, item, index)
|
self._maybe_add_rename_action(menu, item, index)
|
||||||
self._maybe_add_search_actions(menu)
|
self._maybe_add_search_actions(menu)
|
||||||
self._maybe_add_tree_actions(menu)
|
self._maybe_add_tree_actions(menu)
|
||||||
|
gui_hooks.browser_sidebar_will_show_context_menu(self, menu, item, index)
|
||||||
if menu.children():
|
if menu.children():
|
||||||
menu.exec_(QCursor.pos())
|
menu.exec_(QCursor.pos())
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ from anki.decks import DeckDict, DeckConfigDict
|
|||||||
from anki.hooks import runFilter, runHook
|
from anki.hooks import runFilter, runHook
|
||||||
from anki.models import NotetypeDict
|
from anki.models import NotetypeDict
|
||||||
from anki.collection import OpChangesAfterUndo
|
from anki.collection import OpChangesAfterUndo
|
||||||
from aqt.qt import QDialog, QEvent, QMenu, QWidget
|
from aqt.qt import QDialog, QEvent, QMenu, QModelIndex, QWidget
|
||||||
from aqt.tagedit import TagEdit
|
from aqt.tagedit import TagEdit
|
||||||
from aqt.undo import UndoActionsInfo
|
from aqt.undo import UndoActionsInfo
|
||||||
"""
|
"""
|
||||||
@ -354,6 +354,15 @@ hooks = [
|
|||||||
args=["browser: aqt.browser.Browser", "menu: QMenu"],
|
args=["browser: aqt.browser.Browser", "menu: QMenu"],
|
||||||
legacy_hook="browser.onContextMenu",
|
legacy_hook="browser.onContextMenu",
|
||||||
),
|
),
|
||||||
|
Hook(
|
||||||
|
name="browser_sidebar_will_show_context_menu",
|
||||||
|
args=[
|
||||||
|
"sidebar: aqt.browser.SidebarTreeView",
|
||||||
|
"menu: QMenu",
|
||||||
|
"item: aqt.browser.SidebarItem",
|
||||||
|
"index: QModelIndex",
|
||||||
|
],
|
||||||
|
),
|
||||||
Hook(
|
Hook(
|
||||||
name="browser_header_will_show_context_menu",
|
name="browser_header_will_show_context_menu",
|
||||||
args=["browser: aqt.browser.Browser", "menu: QMenu"],
|
args=["browser: aqt.browser.Browser", "menu: QMenu"],
|
||||||
|
Loading…
Reference in New Issue
Block a user