mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Add hooks for context menus
This commit is contained in:
parent
c0454fe3e7
commit
e5bc1650f9
4 changed files with 6 additions and 1 deletions
|
@ -8,7 +8,7 @@ import aqt.forms
|
||||||
from aqt.utils import saveGeom, restoreGeom, showWarning, askUser, shortcut, \
|
from aqt.utils import saveGeom, restoreGeom, showWarning, askUser, shortcut, \
|
||||||
tooltip, openHelp, addCloseShortcut
|
tooltip, openHelp, addCloseShortcut
|
||||||
from anki.sound import clearAudioQueue
|
from anki.sound import clearAudioQueue
|
||||||
from anki.hooks import addHook, remHook
|
from anki.hooks import addHook, remHook, runHook
|
||||||
from anki.utils import stripHTMLMedia, isMac
|
from anki.utils import stripHTMLMedia, isMac
|
||||||
import aqt.editor, aqt.modelchooser, aqt.deckchooser
|
import aqt.editor, aqt.modelchooser, aqt.deckchooser
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ class AddCards(QDialog):
|
||||||
a = m.addAction(_("Edit %s") % txt)
|
a = m.addAction(_("Edit %s") % txt)
|
||||||
a.connect(a, SIGNAL("triggered()"),
|
a.connect(a, SIGNAL("triggered()"),
|
||||||
lambda nid=nid: self.editHistory(nid))
|
lambda nid=nid: self.editHistory(nid))
|
||||||
|
runHook("AddCards.onHistory", self, m)
|
||||||
m.exec_(self.historyButton.mapToGlobal(QPoint(0,0)))
|
m.exec_(self.historyButton.mapToGlobal(QPoint(0,0)))
|
||||||
|
|
||||||
def editHistory(self, nid):
|
def editHistory(self, nid):
|
||||||
|
|
|
@ -1174,4 +1174,5 @@ class EditorWebView(AnkiWebView):
|
||||||
a.connect(a, SIGNAL("triggered()"), self.onCopy)
|
a.connect(a, SIGNAL("triggered()"), self.onCopy)
|
||||||
a = m.addAction(_("Paste"))
|
a = m.addAction(_("Paste"))
|
||||||
a.connect(a, SIGNAL("triggered()"), self.onPaste)
|
a.connect(a, SIGNAL("triggered()"), self.onPaste)
|
||||||
|
runHook("EditorWebView.contextMenuEvent", self, m)
|
||||||
m.popup(QCursor.pos())
|
m.popup(QCursor.pos())
|
||||||
|
|
|
@ -693,6 +693,7 @@ function showAnswer(txt) {
|
||||||
a = m.addAction(label)
|
a = m.addAction(label)
|
||||||
a.setShortcut(QKeySequence(scut))
|
a.setShortcut(QKeySequence(scut))
|
||||||
a.connect(a, SIGNAL("triggered()"), func)
|
a.connect(a, SIGNAL("triggered()"), func)
|
||||||
|
runHook("Reviewer.contextMenuEvent",self,m)
|
||||||
m.exec_(QCursor.pos())
|
m.exec_(QCursor.pos())
|
||||||
|
|
||||||
def onOptions(self):
|
def onOptions(self):
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
from anki.hooks import runHook
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.utils import openLink
|
from aqt.utils import openLink
|
||||||
from anki.utils import isMac, isWin
|
from anki.utils import isMac, isWin
|
||||||
|
@ -85,6 +86,7 @@ class AnkiWebView(QWebView):
|
||||||
a = m.addAction(_("Copy"))
|
a = m.addAction(_("Copy"))
|
||||||
a.connect(a, SIGNAL("triggered()"),
|
a.connect(a, SIGNAL("triggered()"),
|
||||||
lambda: self.triggerPageAction(QWebPage.Copy))
|
lambda: self.triggerPageAction(QWebPage.Copy))
|
||||||
|
runHook("AnkiWebView.contextMenuEvent", self, m)
|
||||||
m.popup(QCursor.pos())
|
m.popup(QCursor.pos())
|
||||||
|
|
||||||
def dropEvent(self, evt):
|
def dropEvent(self, evt):
|
||||||
|
|
Loading…
Reference in a new issue