mirror of
https://github.com/ankitects/anki.git
synced 2025-11-14 16:47:12 -05:00
make sure to save fields on drag/drop
This commit is contained in:
parent
d62b12de90
commit
8f4d2d85d3
1 changed files with 10 additions and 6 deletions
|
|
@ -1010,12 +1010,16 @@ class FactEdit(QTextEdit):
|
||||||
source.hasHtml())
|
source.hasHtml())
|
||||||
|
|
||||||
def insertFromMimeData(self, source):
|
def insertFromMimeData(self, source):
|
||||||
|
if self._insertFromMimeData(source):
|
||||||
|
self.emit(SIGNAL("lostFocus"))
|
||||||
|
|
||||||
|
def _insertFromMimeData(self, source):
|
||||||
pics = ("jpg", "jpeg", "png", "tif", "tiff", "gif")
|
pics = ("jpg", "jpeg", "png", "tif", "tiff", "gif")
|
||||||
audio = ("wav", "mp3", "ogg", "flac")
|
audio = ("wav", "mp3", "ogg", "flac")
|
||||||
errtxt = _("An error occured while opening %s")
|
errtxt = _("An error occured while opening %s")
|
||||||
if source.hasHtml() and "qrichtext" in unicode(source.html()):
|
if source.hasHtml() and "qrichtext" in unicode(source.html()):
|
||||||
self.insertHtml(source.html())
|
self.insertHtml(source.html())
|
||||||
return
|
return True
|
||||||
if source.hasText() and (ankiqt.mw.config['stripHTML'] or
|
if source.hasText() and (ankiqt.mw.config['stripHTML'] or
|
||||||
not source.hasHtml()):
|
not source.hasHtml()):
|
||||||
txt = unicode(source.text())
|
txt = unicode(source.text())
|
||||||
|
|
@ -1041,12 +1045,12 @@ class FactEdit(QTextEdit):
|
||||||
else:
|
else:
|
||||||
# not image or sound, treat as plain text
|
# not image or sound, treat as plain text
|
||||||
self.insertPlainText(source.text())
|
self.insertPlainText(source.text())
|
||||||
|
return True
|
||||||
except urllib2.URLError, e:
|
except urllib2.URLError, e:
|
||||||
ui.utils.showWarning(errtxt % e)
|
ui.utils.showWarning(errtxt % e)
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
self.insertPlainText(source.text())
|
self.insertPlainText(source.text())
|
||||||
return
|
return True
|
||||||
if source.hasImage():
|
if source.hasImage():
|
||||||
im = QImage(source.imageData())
|
im = QImage(source.imageData())
|
||||||
if im.hasAlphaChannel():
|
if im.hasAlphaChannel():
|
||||||
|
|
@ -1058,7 +1062,7 @@ class FactEdit(QTextEdit):
|
||||||
uname = unicode(name, sys.getfilesystemencoding())
|
uname = unicode(name, sys.getfilesystemencoding())
|
||||||
im.save(uname, None, 95)
|
im.save(uname, None, 95)
|
||||||
self.parent._addPicture(uname, widget=self)
|
self.parent._addPicture(uname, widget=self)
|
||||||
return
|
return True
|
||||||
if source.hasUrls():
|
if source.hasUrls():
|
||||||
for url in source.urls():
|
for url in source.urls():
|
||||||
url = unicode(url.toString())
|
url = unicode(url.toString())
|
||||||
|
|
@ -1072,10 +1076,10 @@ class FactEdit(QTextEdit):
|
||||||
self.parent._addSound(name, widget=self)
|
self.parent._addSound(name, widget=self)
|
||||||
except urllib2.URLError, e:
|
except urllib2.URLError, e:
|
||||||
ui.utils.showWarning(errtxt % e)
|
ui.utils.showWarning(errtxt % e)
|
||||||
return
|
return True
|
||||||
if source.hasHtml():
|
if source.hasHtml():
|
||||||
self.insertHtml(self.simplifyHTML(unicode(source.html())))
|
self.insertHtml(self.simplifyHTML(unicode(source.html())))
|
||||||
return
|
return True
|
||||||
|
|
||||||
def _retrieveURL(self, url):
|
def _retrieveURL(self, url):
|
||||||
req = urllib2.Request(url, None, {
|
req = urllib2.Request(url, None, {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue