mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
prefer image if text starts with http
This commit is contained in:
parent
22658dea73
commit
53cb4790af
1 changed files with 9 additions and 3 deletions
|
@ -570,14 +570,20 @@ class FactEdit(QTextEdit):
|
||||||
|
|
||||||
def insertFromMimeData(self, source):
|
def insertFromMimeData(self, source):
|
||||||
if source.hasText():
|
if source.hasText():
|
||||||
|
if not (unicode(source.text()).lower().startswith("http://") and
|
||||||
|
source.hasImage()):
|
||||||
|
# choose text unless this is a link with an image
|
||||||
self.insertPlainText(source.text())
|
self.insertPlainText(source.text())
|
||||||
elif source.hasImage():
|
return
|
||||||
|
if source.hasImage():
|
||||||
im = QImage(source.imageData())
|
im = QImage(source.imageData())
|
||||||
(fd, name) = tempfile.mkstemp(suffix=".jpg")
|
(fd, name) = tempfile.mkstemp(suffix=".jpg")
|
||||||
im.save(name, None, 95)
|
im.save(name, None, 95)
|
||||||
self.parent._addPicture(name, widget=self)
|
self.parent._addPicture(name, widget=self)
|
||||||
elif source.hasHtml():
|
return
|
||||||
|
if source.hasHtml():
|
||||||
self.insertHtml(self.simplifyHTML(unicode(source.html())))
|
self.insertHtml(self.simplifyHTML(unicode(source.html())))
|
||||||
|
return
|
||||||
|
|
||||||
def simplifyHTML(self, html):
|
def simplifyHTML(self, html):
|
||||||
"Remove all style information and P tags."
|
"Remove all style information and P tags."
|
||||||
|
|
Loading…
Reference in a new issue