mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
copy&paste images, make sort and tags in editor longer
This commit is contained in:
parent
7a27c8efeb
commit
22f4f439f0
2 changed files with 13 additions and 2 deletions
|
@ -235,6 +235,7 @@ class EditDeck(QMainWindow):
|
||||||
self.tagChanged)
|
self.tagChanged)
|
||||||
|
|
||||||
def setupSort(self):
|
def setupSort(self):
|
||||||
|
self.dialog.sortBox.setMaxVisibleItems(30)
|
||||||
self.sortIndex = self.config['sortIndex']
|
self.sortIndex = self.config['sortIndex']
|
||||||
self.drawSort()
|
self.drawSort()
|
||||||
self.connect(self.dialog.sortBox, SIGNAL("activated(int)"),
|
self.connect(self.dialog.sortBox, SIGNAL("activated(int)"),
|
||||||
|
@ -242,6 +243,7 @@ class EditDeck(QMainWindow):
|
||||||
self.sortChanged(self.sortIndex, refresh=False)
|
self.sortChanged(self.sortIndex, refresh=False)
|
||||||
|
|
||||||
def drawTags(self):
|
def drawTags(self):
|
||||||
|
self.dialog.tagList.setMaxVisibleItems(30)
|
||||||
tags = self.deck.allTags()
|
tags = self.deck.allTags()
|
||||||
self.alltags = tags
|
self.alltags = tags
|
||||||
self.alltags.sort()
|
self.alltags.sort()
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
import re, os, sys
|
import re, os, sys, tempfile
|
||||||
from anki.utils import stripHTML, tidyHTML, canonifyTags
|
from anki.utils import stripHTML, tidyHTML, canonifyTags
|
||||||
from anki.sound import playFromText
|
from anki.sound import playFromText
|
||||||
import anki.sound
|
import anki.sound
|
||||||
|
@ -540,6 +540,10 @@ class FactEditor(object):
|
||||||
file = ui.utils.getFile(self.parent, _("Add an image"), "picture", key)
|
file = ui.utils.getFile(self.parent, _("Add an image"), "picture", key)
|
||||||
if not file:
|
if not file:
|
||||||
return
|
return
|
||||||
|
self._addPicture(file)
|
||||||
|
|
||||||
|
def _addPicture(self, file):
|
||||||
|
w = self.focusedEdit()
|
||||||
path = self.deck.addMedia(file)
|
path = self.deck.addMedia(file)
|
||||||
w.insertHtml('<img src="%s">' % path)
|
w.insertHtml('<img src="%s">' % path)
|
||||||
|
|
||||||
|
@ -562,7 +566,12 @@ class FactEdit(QTextEdit):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
def insertFromMimeData(self, source):
|
def insertFromMimeData(self, source):
|
||||||
if source.hasText():
|
if source.hasImage():
|
||||||
|
im = QImage(source.imageData())
|
||||||
|
(fd, name) = tempfile.mkstemp(suffix=".jpg")
|
||||||
|
im.save(name, None, 95)
|
||||||
|
self.parent._addPicture(name)
|
||||||
|
elif source.hasText():
|
||||||
self.insertPlainText(source.text())
|
self.insertPlainText(source.text())
|
||||||
elif source.hasHtml():
|
elif source.hasHtml():
|
||||||
self.insertHtml(self.simplyHTML(unicode(source.html())))
|
self.insertHtml(self.simplyHTML(unicode(source.html())))
|
||||||
|
|
Loading…
Reference in a new issue