mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
add option to paste as pngs; compress pngs
This commit is contained in:
parent
2279704a11
commit
b1ba96d517
4 changed files with 24 additions and 8 deletions
|
@ -1075,14 +1075,19 @@ class EditorWebView(AnkiWebView):
|
|||
|
||||
def _processImage(self, mime):
|
||||
im = QImage(mime.imageData())
|
||||
name = namedtmp("paste-%d.png" % im.cacheKey())
|
||||
name = namedtmp("paste-%d" % im.cacheKey())
|
||||
uname = unicode(name, sys.getfilesystemencoding())
|
||||
if im.hasAlphaChannel():
|
||||
im.save(uname)
|
||||
if self.editor.mw.pm.profile.get("pastePNG", False):
|
||||
ext = ".png"
|
||||
im.save(uname+ext, None, 50)
|
||||
else:
|
||||
im.save(uname, None, 95)
|
||||
ext = ".jpg"
|
||||
im.save(uname+ext, None, 80)
|
||||
# invalid image?
|
||||
if not os.path.exists(uname+ext):
|
||||
return QMimeData()
|
||||
mime = QMimeData()
|
||||
mime.setHtml(self.editor._addMedia(uname))
|
||||
mime.setHtml(self.editor._addMedia(uname+ext))
|
||||
return mime
|
||||
|
||||
def _retrieveURL(self, url):
|
||||
|
|
|
@ -128,12 +128,14 @@ Not currently enabled; click the sync button in the main window to enable."""))
|
|||
|
||||
def setupOptions(self):
|
||||
self.form.stripHTML.setChecked(self.prof['stripHTML'])
|
||||
self.form.pastePNG.setChecked(self.prof.get("pastePNG", False))
|
||||
self.connect(
|
||||
self.form.profilePass, SIGNAL("clicked()"),
|
||||
self.onProfilePass)
|
||||
|
||||
def updateOptions(self):
|
||||
self.prof['stripHTML'] = self.form.stripHTML.isChecked()
|
||||
self.prof['pastePNG'] = self.form.pastePNG.isChecked()
|
||||
|
||||
def onProfilePass(self):
|
||||
pw, ret = getText(_("""\
|
||||
|
|
|
@ -42,6 +42,7 @@ profileConf = dict(
|
|||
editFontFamily=fontForPlatform(),
|
||||
editFontSize=12,
|
||||
editLineSize=20,
|
||||
pastePNG=False,
|
||||
# not exposed in gui
|
||||
deleteMedia=False,
|
||||
preserveKeyboard=True,
|
||||
|
|
|
@ -44,6 +44,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useCurrent">
|
||||
<property name="text">
|
||||
<string>Use the current deck as the default when adding notes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="stripHTML">
|
||||
<property name="text">
|
||||
|
@ -52,9 +59,9 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useCurrent">
|
||||
<widget class="QCheckBox" name="pastePNG">
|
||||
<property name="text">
|
||||
<string>Use the current deck as the default when adding notes</string>
|
||||
<string>Paste clipboard images as PNG</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -464,8 +471,9 @@
|
|||
<tabstops>
|
||||
<tabstop>showEstimates</tabstop>
|
||||
<tabstop>showProgress</tabstop>
|
||||
<tabstop>stripHTML</tabstop>
|
||||
<tabstop>useCurrent</tabstop>
|
||||
<tabstop>stripHTML</tabstop>
|
||||
<tabstop>pastePNG</tabstop>
|
||||
<tabstop>newSpread</tabstop>
|
||||
<tabstop>dayOffset</tabstop>
|
||||
<tabstop>lrnCutoff</tabstop>
|
||||
|
|
Loading…
Reference in a new issue