diff --git a/anki/exporting.py b/anki/exporting.py index 47288a1ce..2cbdfc53e 100644 --- a/anki/exporting.py +++ b/anki/exporting.py @@ -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 ###################################################################### diff --git a/anki/media.py b/anki/media.py index a96135315..89fcbe69c 100644 --- a/anki/media.py +++ b/anki/media.py @@ -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) diff --git a/anki/stats.py b/anki/stats.py index bddf6119a..197e941a9 100644 --- a/anki/stats.py +++ b/anki/stats.py @@ -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 diff --git a/anki/template/template.py b/anki/template/template.py index d2f055c61..33bfd6ea8 100644 --- a/anki/template/template.py +++ b/anki/template/template.py @@ -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: diff --git a/aqt/about.py b/aqt/about.py index 408c5fa17..e7945d5f8 100644 --- a/aqt/about.py +++ b/aqt/about.py @@ -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 diff --git a/aqt/addcards.py b/aqt/addcards.py index 3dcf46184..dd1de4d43 100644 --- a/aqt/addcards.py +++ b/aqt/addcards.py @@ -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 diff --git a/aqt/browser.py b/aqt/browser.py index 47cdd6777..dcd1603c3 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -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) diff --git a/aqt/deckbrowser.py b/aqt/deckbrowser.py index 74ad1b0a3..60cbf1d9e 100644 --- a/aqt/deckbrowser.py +++ b/aqt/deckbrowser.py @@ -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) diff --git a/aqt/editcurrent.py b/aqt/editcurrent.py index c029fc36e..cb8d69067 100644 --- a/aqt/editcurrent.py +++ b/aqt/editcurrent.py @@ -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 diff --git a/aqt/editor.py b/aqt/editor.py index ce76ebe3f..755bfbd7e 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -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.")) diff --git a/aqt/main.py b/aqt/main.py index cdcc41a2f..0d90cf6af 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -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) diff --git a/aqt/profiles.py b/aqt/profiles.py index ccf90fa47..4503240d6 100644 --- a/aqt/profiles.py +++ b/aqt/profiles.py @@ -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) diff --git a/aqt/qt.py b/aqt/qt.py index a46aec0b9..328f82110 100644 --- a/aqt/qt.py +++ b/aqt/qt.py @@ -49,8 +49,3 @@ if qtmajor <= 4 and qtminor <= 6: import anki.template.furigana anki.template.furigana.ruby = r'\2\1' -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 diff --git a/aqt/reviewer.py b/aqt/reviewer.py index 79216e00b..4c17c7596 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -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); } diff --git a/aqt/stats.py b/aqt/stats.py index 93bf6601a..b7c6e0c54 100644 --- a/aqt/stats.py +++ b/aqt/stats.py @@ -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", diff --git a/aqt/webview.py b/aqt/webview.py index 3be755315..5afd0f72e 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -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("""