Support extended drag & drop
This commit is contained in:
parent
340c749d4c
commit
151f854fa2
@ -54,7 +54,7 @@ neitrinoweb <github.com/neitrinoweb/>
|
|||||||
Andreas Reis <github.com/rathsky>
|
Andreas Reis <github.com/rathsky>
|
||||||
Matt Krump <github.com/mkrump>
|
Matt Krump <github.com/mkrump>
|
||||||
Alexander Presnyakov <flagist0@gmail.com>
|
Alexander Presnyakov <flagist0@gmail.com>
|
||||||
abdo <github.com/ANH25>
|
abdo <github.com/abdnh>
|
||||||
aplaice <plaice.adam+github@gmail.com>
|
aplaice <plaice.adam+github@gmail.com>
|
||||||
phwoo <github.com/phwoo>
|
phwoo <github.com/phwoo>
|
||||||
Soren Bjornstad <anki@sorenbjornstad.com>
|
Soren Bjornstad <anki@sorenbjornstad.com>
|
||||||
|
@ -923,7 +923,7 @@ to a cloze type first, via 'Notes>Change Note Type'"""
|
|||||||
def doDrop(self, html, internal):
|
def doDrop(self, html, internal):
|
||||||
def pasteIfField(ret):
|
def pasteIfField(ret):
|
||||||
if ret:
|
if ret:
|
||||||
self.doPaste(html, internal)
|
self.doPaste(html, internal, self.web._wantsExtendedPaste())
|
||||||
|
|
||||||
p = self.web.mapFromGlobal(QCursor.pos())
|
p = self.web.mapFromGlobal(QCursor.pos())
|
||||||
self.web.evalWithCallback(f"focusIfField({p.x()}, {p.y()});", pasteIfField)
|
self.web.evalWithCallback(f"focusIfField({p.x()}, {p.y()});", pasteIfField)
|
||||||
@ -1028,10 +1028,14 @@ class EditorWebView(AnkiWebView):
|
|||||||
def onCopy(self):
|
def onCopy(self):
|
||||||
self.triggerPageAction(QWebEnginePage.Copy)
|
self.triggerPageAction(QWebEnginePage.Copy)
|
||||||
|
|
||||||
def _onPaste(self, mode: QClipboard.Mode) -> None:
|
def _wantsExtendedPaste(self) -> bool:
|
||||||
extended = not (self.editor.mw.app.queryKeyboardModifiers() & Qt.ShiftModifier)
|
extended = not (self.editor.mw.app.queryKeyboardModifiers() & Qt.ShiftModifier)
|
||||||
if self.editor.mw.pm.profile.get("pasteInvert", False):
|
if self.editor.mw.pm.profile.get("pasteInvert", False):
|
||||||
extended = not extended
|
extended = not extended
|
||||||
|
return extended
|
||||||
|
|
||||||
|
def _onPaste(self, mode: QClipboard.Mode) -> None:
|
||||||
|
extended = self._wantsExtendedPaste()
|
||||||
mime = self.editor.mw.app.clipboard().mimeData(mode=mode)
|
mime = self.editor.mw.app.clipboard().mimeData(mode=mode)
|
||||||
html, internal = self._processMime(mime)
|
html, internal = self._processMime(mime)
|
||||||
if not html:
|
if not html:
|
||||||
|
Loading…
Reference in New Issue
Block a user