filter middle click pastes

This commit is contained in:
Damien Elmes 2018-03-02 11:16:02 +10:00
parent ee940cfa85
commit dc6ebca944
2 changed files with 16 additions and 2 deletions

View File

@ -789,14 +789,20 @@ class EditorWebView(AnkiWebView):
def onCopy(self):
self.triggerPageAction(QWebEnginePage.Copy)
def onPaste(self):
def _onPaste(self, mode):
extended = self.editor.mw.app.queryKeyboardModifiers() & Qt.ShiftModifier
mime = self.editor.mw.app.clipboard().mimeData(mode=QClipboard.Clipboard)
mime = self.editor.mw.app.clipboard().mimeData(mode=mode)
html, internal = self._processMime(mime)
if not html:
return
self.editor.doPaste(html, internal, extended)
def onPaste(self):
self._onPaste(QClipboard.Clipboard)
def onMiddleClickPaste(self):
self._onPaste(QClipboard.Selection)
def dropEvent(self, evt):
mime = evt.mimeData()

View File

@ -108,6 +108,11 @@ class AnkiWebView(QWebEngineView):
# disable pinch to zoom gesture
if isinstance(evt, QNativeGestureEvent):
return True
elif evt.type() == QEvent.MouseButtonRelease:
if evt.button() == Qt.MidButton and isLin:
self.onMiddleClickPaste()
return True
return False
return False
def onEsc(self):
@ -133,6 +138,9 @@ class AnkiWebView(QWebEngineView):
def onPaste(self):
self.triggerPageAction(QWebEnginePage.Paste)
def onMiddleClickPaste(self):
self.triggerPageAction(QWebEnginePage.Paste)
def onSelectAll(self):
self.triggerPageAction(QWebEnginePage.SelectAll)