Merge pull request #767 from abdnh/context-menu-copy-image

Allow copying of images using context menu
This commit is contained in:
Damien Elmes 2020-09-24 10:57:13 +10:00 committed by GitHub
commit c6ea97b69c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -266,7 +266,12 @@ class AnkiWebView(QWebEngineView):
w = w.parent() w = w.parent()
def onCopy(self): def onCopy(self):
self.triggerPageAction(QWebEnginePage.Copy) if not self.selectedText():
ctx = self._page.contextMenuData()
if ctx and ctx.mediaType() == QWebEngineContextMenuData.MediaTypeImage:
self.triggerPageAction(QWebEnginePage.CopyImageToClipboard)
else:
self.triggerPageAction(QWebEnginePage.Copy)
def onCut(self): def onCut(self):
self.triggerPageAction(QWebEnginePage.Cut) self.triggerPageAction(QWebEnginePage.Cut)