mirror of
https://github.com/ankitects/anki.git
synced 2025-11-07 13:17:12 -05:00
catch pastes too
This commit is contained in:
parent
fadf6fd249
commit
0499dd6cae
1 changed files with 10 additions and 0 deletions
|
|
@ -787,9 +787,13 @@ class EditorWebView(AnkiWebView):
|
||||||
|
|
||||||
def keyPressEvent(self, evt):
|
def keyPressEvent(self, evt):
|
||||||
self._curKey = True
|
self._curKey = True
|
||||||
|
if evt.matches(QKeySequence.Paste):
|
||||||
|
self.onPaste()
|
||||||
return QWebView.keyPressEvent(self, evt)
|
return QWebView.keyPressEvent(self, evt)
|
||||||
|
|
||||||
def contextMenuEvent(self, evt):
|
def contextMenuEvent(self, evt):
|
||||||
|
# adjust in case the user is going to paste
|
||||||
|
self.onPaste()
|
||||||
QWebView.contextMenuEvent(self, evt)
|
QWebView.contextMenuEvent(self, evt)
|
||||||
|
|
||||||
def dropEvent(self, evt):
|
def dropEvent(self, evt):
|
||||||
|
|
@ -813,6 +817,12 @@ class EditorWebView(AnkiWebView):
|
||||||
evt.accept()
|
evt.accept()
|
||||||
QWebView.dropEvent(self, new)
|
QWebView.dropEvent(self, new)
|
||||||
|
|
||||||
|
def onPaste(self):
|
||||||
|
clip = self.editor.mw.app.clipboard()
|
||||||
|
mime = clip.mimeData()
|
||||||
|
mime = self._processMime(mime)
|
||||||
|
clip.setMimeData(mime)
|
||||||
|
|
||||||
def _processMime(self, mime):
|
def _processMime(self, mime):
|
||||||
print "html=%s image=%s urls=%s txt=%s" % (
|
print "html=%s image=%s urls=%s txt=%s" % (
|
||||||
mime.hasHtml(), mime.hasImage(), mime.hasUrls(), mime.hasText())
|
mime.hasHtml(), mime.hasImage(), mime.hasUrls(), mime.hasText())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue