This commit is contained in:
Houssam Salem 2014-03-16 22:23:29 +11:00
commit b4057152f7
16 changed files with 24 additions and 20 deletions

View file

@ -214,9 +214,7 @@ class AnkiExporter(Exporter):
pass
def removeSystemTags(self, tags):
tags = ' '.join(tag for tag in tags.split()
if (tag.lower() != "marked" and tag.lower() != "leech"))
return tags
return self.src.tags.remFromStr("marked leech", tags)
# Packaged Anki decks
######################################################################

View file

@ -340,7 +340,7 @@ class MediaManager(object):
# Illegal characters
##########################################################################
_illegalCharReg = re.compile(r'[][><:"/?*^\\|\0]')
_illegalCharReg = re.compile(r'[][><:"/?*^\\|\0\r\n]')
def stripIllegal(self, str):
return re.sub(self._illegalCharReg, "", str)

View file

@ -705,7 +705,7 @@ select
sum(case when queue=2 and ivl >= 21 then 1 else 0 end), -- mtr
sum(case when queue in (1,3) or (queue=2 and ivl < 21) then 1 else 0 end), -- yng/lrn
sum(case when queue=0 then 1 else 0 end), -- new
sum(case when queue=-1 then 1 else 0 end) -- susp
sum(case when queue<0 then 1 else 0 end) -- susp
from cards where did in %s""" % self._limit())
# Footer

View file

@ -191,6 +191,7 @@ class Template(object):
txt = self.clozeText(txt, extra, mod[1]) if txt and extra else ""
else:
# hook-based field modifier
mod, extra = re.search("^(.*?)(?:\((.*)\))?$", mod).groups()
txt = runFilter('fmod_' + mod, txt or '', extra, context,
tag, tag_name);
if txt is None:

View file

@ -31,7 +31,7 @@ system. It's free and open source.")
Alex Fraser, Andreas Klauer, Andrew Wright, Bernhard Ibertsberger, Charlene Barina,
Christian Krause, Christian Rusche, David Smith, Dave Druelinger, Dotan Cohen,
Emilio Wuerges, Emmanuel Jarri, Frank Harper, Gregor Skumavc, H. Mijail,
Ian Lewis, Immanuel Asmus, Iroiro, Jarvik7,
Houssam Salem, Ian Lewis, Immanuel Asmus, Iroiro, Jarvik7,
Jin Eun-Deok, Jo Nakashima, Johanna Lindh, Kieran Clancy, LaC, Laurent Steffan,
Luca Ban, Luciano Esposito, Marco Giancotti, Marcus Rubeus, Mari Egami, Michael Jürges, Mark Wilbur,
Matthew Duggan, Matthew Holtz, Meelis Vasser, Michael Keppler, Michael

View file

@ -190,6 +190,7 @@ question on all cards."""), help="AddItems")
saveGeom(self, "add")
aqt.dialogs.close("AddCards")
QDialog.reject(self)
self.deleteLater()
def canClose(self):
if (self.forceClose or self.editor.fieldsAreBlank() or

View file

@ -373,6 +373,11 @@ class Browser(QMainWindow):
self.onSearch()
self.show()
def _headerKey(self):
if qtmajor >= 5:
return "editor2"
return "editor"
def setupToolbar(self):
self.toolbarWeb = AnkiWebView()
self.toolbarWeb.setFixedHeight(32 + self.mw.fontHeightDelta)
@ -458,7 +463,7 @@ class Browser(QMainWindow):
self.editor.setNote(None)
saveGeom(self, "editor")
saveState(self, "editor")
saveHeader(self.form.tableView.horizontalHeader(), "editor")
saveHeader(self.form.tableView.horizontalHeader(), self._headerKey())
self.col.conf['activeCols'] = self.model.activeCols
self.col.setMod()
self.hide()
@ -466,6 +471,7 @@ class Browser(QMainWindow):
self.teardownHooks()
self.mw.maybeReset()
evt.accept()
self.deleteLater()
def canClose(self):
return True
@ -623,7 +629,7 @@ class Browser(QMainWindow):
if not isWin:
vh.hide()
hh.show()
restoreHeader(hh, "editor")
restoreHeader(hh, self._headerKey())
hh.setHighlightSections(False)
hh.setMinimumSectionSize(50)
hh.setMovable(True)

View file

@ -345,7 +345,7 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000)
if isMac:
size = 28
else:
size = 36 + self.mw.fontHeightDelta*3
size = 38 + self.mw.fontHeightDelta*3
self.bottom.web.setFixedHeight(size)
self.bottom.web.setLinkHandler(self._linkHandler)

View file

@ -64,6 +64,7 @@ class EditCurrent(QDialog):
self.mw.moveToState("review")
saveGeom(self, "editcurrent")
aqt.dialogs.close("EditCurrent")
self.deleteLater()
def canClose(self):
return True

View file

@ -690,7 +690,7 @@ class Editor(object):
def onCloze(self):
# check that the model is set up for cloze deletion
if '{{cloze:' not in self.note.model()['tmpls'][0]['qfmt']:
if not re.search('{{(.*:)*cloze:',self.note.model()['tmpls'][0]['qfmt']):
if self.addMode:
tooltip(_("Warning, cloze deletions will not work until "
"you switch the type at the top to Cloze."))

View file

@ -1084,7 +1084,7 @@ will be lost. Continue?"""))
def setupFonts(self):
f = QFontInfo(self.font())
ws = QWebSettings.globalSettings()
self.fontHeight = f.pixelSize()
self.fontHeight = max(14, f.pixelSize())
self.fontFamily = f.family()
self.fontHeightDelta = max(0, self.fontHeight - 13)
ws.setFontFamily(QWebSettings.StandardFont, self.fontFamily)

View file

@ -179,7 +179,7 @@ documentation for information on using a flash drive.""")
def _defaultBase(self):
if isWin:
if qtmajor >= 5:
if False: #qtmajor >= 5:
loc = QStandardPaths.writeableLocation(QStandardPaths.DocumentsLocation)
else:
loc = QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)

View file

@ -49,8 +49,3 @@ if qtmajor <= 4 and qtminor <= 6:
import anki.template.furigana
anki.template.furigana.ruby = r'<span style="display: inline-block; text-align: center; line-height: 1; white-space: nowrap; vertical-align: baseline; margin: 0; padding: 0"><span style="display: block; text-decoration: none; line-height: 1.2; font-weight: normal; font-size: 0.64em">\2</span>\1</span>'
if isWin or isMac:
# we no longer use this, but want it included in the mac+win builds
# so we don't break add-ons that use it. any new add-ons should use
# the above variables instead
from PyQt4 import pyqtconfig

View file

@ -47,7 +47,7 @@ class Reviewer(object):
if isMac:
self.bottom.web.setFixedHeight(46)
else:
self.bottom.web.setFixedHeight(52+self.mw.fontHeightDelta*4)
self.bottom.web.setFixedHeight(54+self.mw.fontHeightDelta*4)
self.bottom.web.setLinkHandler(self._linkHandler)
self._reps = None
self.nextCard()
@ -134,7 +134,8 @@ function _updateQA (q, answerMode, klass) {
typeans.focus();
}
if (answerMode) {
window.location = "#answer";
var e = $("#answer");
if (e[0]) { e[0].scrollIntoView(); }
} else {
window.scrollTo(0, 0);
}

View file

@ -45,6 +45,7 @@ class DeckStats(QDialog):
def reject(self):
saveGeom(self, self.name)
QDialog.reject(self)
self.deleteLater()
def browser(self):
name = time.strftime("-%Y-%m-%d@%H-%M-%S.png",

View file

@ -109,7 +109,7 @@ class AnkiWebView(QWebView):
def stdHtml(self, body, css="", bodyClass="", loadCB=None, js=None, head=""):
if isMac:
button = "font-weight: bold; height: 24px;"
button = "font-weight: normal; height: 24px;"
else:
button = "font-weight: normal;"
self.setHtml("""