mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Fix pasting from the primary selection (#3413)
* Fix clipboard pasting from the primary selection * Small renaming * Fix submodules * Fix pylint false positive
This commit is contained in:
parent
96ff4f1a4a
commit
0a879bd2ed
2 changed files with 22 additions and 7 deletions
|
@ -163,7 +163,7 @@ Lucas Scharenbroch <lucasscharenbroch@gmail.com>
|
||||||
Antonio Cavallo <a.cavallo@cavallinux.eu>
|
Antonio Cavallo <a.cavallo@cavallinux.eu>
|
||||||
Han Yeong-woo <han@yeongwoo.dev>
|
Han Yeong-woo <han@yeongwoo.dev>
|
||||||
Jean Khawand <jk@jeankhawand.com>
|
Jean Khawand <jk@jeankhawand.com>
|
||||||
Pedro Schreiber <schreiber.mmb@gmail.com>
|
Pedro Schreiber <schreiber.mmb@gmail.com>
|
||||||
Foxy_null <https://github.com/Foxy-null>
|
Foxy_null <https://github.com/Foxy-null>
|
||||||
Arbyste <arbyste@outlook.com>
|
Arbyste <arbyste@outlook.com>
|
||||||
Vasll <github.com/vasll>
|
Vasll <github.com/vasll>
|
||||||
|
@ -187,11 +187,12 @@ Christian Donat <https://github.com/cdonat2>
|
||||||
Asuka Minato <https://asukaminato.eu.org>
|
Asuka Minato <https://asukaminato.eu.org>
|
||||||
Dillon Baldwin <https://github.com/DillBal>
|
Dillon Baldwin <https://github.com/DillBal>
|
||||||
Voczi <https://github.com/voczi>
|
Voczi <https://github.com/voczi>
|
||||||
Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>
|
Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>
|
||||||
Themis Demetriades <themis100@outlook.com>
|
Themis Demetriades <themis100@outlook.com>
|
||||||
Luke Bartholomew <lukesbart@icloud.com>
|
Luke Bartholomew <lukesbart@icloud.com>
|
||||||
Gregory Abrasaldo <degeemon@gmail.com>
|
Gregory Abrasaldo <degeemon@gmail.com>
|
||||||
Taylor Obyen <https://github.com/taylorobyen>
|
Taylor Obyen <https://github.com/taylorobyen>
|
||||||
|
Kris Cherven <krischerven@gmail.com>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
||||||
|
|
|
@ -1452,19 +1452,33 @@ class EditorWebView(AnkiWebView):
|
||||||
return not strip_html
|
return not strip_html
|
||||||
|
|
||||||
def _onPaste(self, mode: QClipboard.Mode) -> None:
|
def _onPaste(self, mode: QClipboard.Mode) -> None:
|
||||||
# Since _on_clipboard_change doesn't always trigger properly on macOS, we do a double check if any changes were made before pasting
|
# Since _on_clipboard_change doesn't always trigger properly on macOS,
|
||||||
|
# we do a double check if any changes were made before pasting
|
||||||
if self._last_known_clipboard_mime != self.editor.mw.app.clipboard().mimeData():
|
if self._last_known_clipboard_mime != self.editor.mw.app.clipboard().mimeData():
|
||||||
self._on_clipboard_change()
|
self._on_clipboard_change()
|
||||||
extended = self._wantsExtendedPaste()
|
extended = self._wantsExtendedPaste()
|
||||||
if html := self._internal_field_text_for_paste:
|
|
||||||
|
def reuse_internal():
|
||||||
print("reuse internal")
|
print("reuse internal")
|
||||||
self.editor.doPaste(html, True, extended)
|
if html := self._internal_field_text_for_paste:
|
||||||
else:
|
self.editor.doPaste(html, True, extended)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def use_clipboard():
|
||||||
print("use clipboard")
|
print("use clipboard")
|
||||||
mime = self.editor.mw.app.clipboard().mimeData(mode=mode)
|
mime = self.editor.mw.app.clipboard().mimeData(mode=mode)
|
||||||
html, internal = self._processMime(mime, extended)
|
html, internal = self._processMime(mime, extended)
|
||||||
if html:
|
if html:
|
||||||
self.editor.doPaste(html, internal, extended)
|
self.editor.doPaste(html, internal, extended)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
if mode == QClipboard.Mode.Selection:
|
||||||
|
if not use_clipboard():
|
||||||
|
reuse_internal()
|
||||||
|
else:
|
||||||
|
reuse_internal()
|
||||||
|
|
||||||
def onPaste(self) -> None:
|
def onPaste(self) -> None:
|
||||||
self._onPaste(QClipboard.Mode.Clipboard)
|
self._onPaste(QClipboard.Mode.Clipboard)
|
||||||
|
|
Loading…
Reference in a new issue