From de8adfecff06e8328530008fb32dde1895bc2c46 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 6 Mar 2014 09:00:47 +0900 Subject: [PATCH 01/12] disallow \r and \n in media filenames --- anki/media.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 8fecf53c3b2b9110adb51345c5883abc77033787 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 6 Mar 2014 09:03:52 +0900 Subject: [PATCH 02/12] use qdesktopservices on qt5+pyqt4 --- aqt/profiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 93414007b813928f7799e1161a2c22618b68a143 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 6 Mar 2014 09:04:28 +0900 Subject: [PATCH 03/12] stop providing pyqtconfig, as it's no longer available on newer plats --- aqt/qt.py | 5 ----- 1 file changed, 5 deletions(-) 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 From e06312321896cfa5d9a080a60998bd8d4efa3b5a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 6 Mar 2014 09:07:03 +0900 Subject: [PATCH 04/12] use a new header key on qt5 to fix drawing bug --- aqt/browser.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aqt/browser.py b/aqt/browser.py index 47cdd6777..e81d620df 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() @@ -623,7 +628,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) From 66908a172ac0320a049954455ab110df75353eba Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 7 Mar 2014 06:47:12 +0900 Subject: [PATCH 05/12] add houssam to about --- aqt/about.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 9beed20dc0e21728c6d2f67e657fd62314af6684 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 7 Mar 2014 10:12:07 +0900 Subject: [PATCH 06/12] tweak heights and font sizes --- aqt/deckbrowser.py | 2 +- aqt/main.py | 2 +- aqt/reviewer.py | 2 +- aqt/webview.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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/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/reviewer.py b/aqt/reviewer.py index 79216e00b..ffc239888 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() 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(""" From fe2c94b819d6c249cca514ecf309b314d51adf5f Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 7 Mar 2014 10:19:18 +0900 Subject: [PATCH 07/12] use different way of scrolling to answer to fix qt5 bug --- aqt/reviewer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aqt/reviewer.py b/aqt/reviewer.py index ffc239888..4c17c7596 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -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); } From 7dcf0d8eadcdcc994e03dc9dd9f4ff435dcec49d Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 9 Mar 2014 10:44:52 +0900 Subject: [PATCH 08/12] fix tag strip on export we must make sure to include spaces around tags or they can't be found --- anki/exporting.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 ###################################################################### From 69a19b58c27695de1569bf8b1e83b9f77f819172 Mon Sep 17 00:00:00 2001 From: Julien Baley Date: Sun, 9 Mar 2014 18:12:39 +0000 Subject: [PATCH 09/12] Fixes creation of Cloze when having a chained modifier on the left of cloze --- aqt/editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.")) From 90fd1c00c8e10aa547252abb0eb3806775debb94 Mon Sep 17 00:00:00 2001 From: Julien Baley Date: Wed, 12 Mar 2014 14:21:23 +0000 Subject: [PATCH 10/12] Adding support for parameters in modifiers: {{mod1(param1,param2):mod2(param3):field}} --- anki/template/template.py | 1 + 1 file changed, 1 insertion(+) 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: From b1cb07077a52da853c3780babf3786bfa7ce6719 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 14 Mar 2014 11:56:15 +0900 Subject: [PATCH 11/12] include buried in suspended count --- anki/stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From b9ba2375a1f13aab90fdc22c3507404c4b691bf3 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 14 Mar 2014 12:51:38 +0900 Subject: [PATCH 12/12] fix some memory leaks --- aqt/addcards.py | 1 + aqt/browser.py | 1 + aqt/editcurrent.py | 1 + aqt/stats.py | 1 + 4 files changed, 4 insertions(+) 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 e81d620df..dcd1603c3 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -471,6 +471,7 @@ class Browser(QMainWindow): self.teardownHooks() self.mw.maybeReset() evt.accept() + self.deleteLater() def canClose(self): return True 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/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",