From 53cb4790af300bf91518b8531de984ce82a76609 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 10 Dec 2008 19:03:15 +0900 Subject: [PATCH] prefer image if text starts with http --- ankiqt/ui/facteditor.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py index 175576254..d88be1522 100644 --- a/ankiqt/ui/facteditor.py +++ b/ankiqt/ui/facteditor.py @@ -570,14 +570,20 @@ class FactEdit(QTextEdit): def insertFromMimeData(self, source): if source.hasText(): - self.insertPlainText(source.text()) - elif source.hasImage(): + 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()) + return + if source.hasImage(): im = QImage(source.imageData()) (fd, name) = tempfile.mkstemp(suffix=".jpg") im.save(name, None, 95) self.parent._addPicture(name, widget=self) - elif source.hasHtml(): + return + if source.hasHtml(): self.insertHtml(self.simplifyHTML(unicode(source.html()))) + return def simplifyHTML(self, html): "Remove all style information and P tags."