From 72b41481279286aad197a5e7406d80529dba6b32 Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Tue, 24 Jun 2014 14:50:39 -0500 Subject: [PATCH 01/11] make sure temp folder hasn't been deleted since creation --- anki/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/anki/utils.py b/anki/utils.py index 6fab82fa1..5452d051b 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -292,9 +292,10 @@ def tmpdir(): shutil.rmtree(_tmpdir) import atexit atexit.register(cleanup) - _tmpdir = unicode(os.path.join(tempfile.gettempdir(), "anki_temp"), sys.getfilesystemencoding()) - if not os.path.exists(_tmpdir): - os.mkdir(_tmpdir) + _tmpdir = unicode(os.path.join(tempfile.gettempdir(), "anki_temp"), \ + sys.getfilesystemencoding()) + if not os.path.exists(_tmpdir): + os.mkdir(_tmpdir) return _tmpdir def tmpfile(prefix="", suffix=""): From 88c36af987e936c6f456341c8a96a36e468f94f4 Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Tue, 24 Jun 2014 15:04:23 -0500 Subject: [PATCH 02/11] don't try to log in if user cancels login dialog --- aqt/sync.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aqt/sync.py b/aqt/sync.py index c54000654..af8ff0d50 100644 --- a/aqt/sync.py +++ b/aqt/sync.py @@ -217,10 +217,10 @@ enter your details below.""") % vbox.addWidget(bb) d.setLayout(vbox) d.show() - d.exec_() + accepted = d.exec_() u = user.text() p = passwd.text() - if not u or not p: + if not accepted or not u or not p: return return (u, p) From a2eb5a09c3a3256f81a103cf1d39f6dec88ce3a6 Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Tue, 17 Jun 2014 17:51:02 -0500 Subject: [PATCH 03/11] allow changing case of profile name on Windows --- aqt/profiles.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/aqt/profiles.py b/aqt/profiles.py index 4503240d6..25aec728d 100644 --- a/aqt/profiles.py +++ b/aqt/profiles.py @@ -140,9 +140,24 @@ documentation for information on using a flash drive.""") self.name = name newFolder = self.profileFolder(create=False) if os.path.exists(newFolder): - showWarning(_("Folder already exists.")) - self.name = oldName - return + if (oldFolder != newFolder) and ( + oldFolder.lower() == newFolder.lower()): + # OS is telling us the folder exists because it does not take + # case into account; use a temporary folder location + midFolder = ''.join([oldFolder, '-temp']) + if not os.path.exists(midFolder): + os.rename(oldFolder, midFolder) + oldFolder = midFolder + else: + showWarning(_("Please remove the folder %s and try again.") + % midFolder) + self.name = oldName + return + else: + showWarning(_("Folder already exists.")) + self.name = oldName + return + # update name self.db.execute("update profiles set name = ? where name = ?", name.encode("utf8"), oldName.encode("utf-8")) From a570779a2623769fb15f06b054c986fffc5af68d Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Tue, 24 Jun 2014 15:55:19 -0500 Subject: [PATCH 04/11] update all duplicates when importing If duplicate notes are already in the collection and, based on the first field of all of them, they should be updated, update all of them instead of just the first one we come across. --- anki/importing/noteimp.py | 1 - 1 file changed, 1 deletion(-) diff --git a/anki/importing/noteimp.py b/anki/importing/noteimp.py index e9e435d67..d53f8a9ac 100644 --- a/anki/importing/noteimp.py +++ b/anki/importing/noteimp.py @@ -156,7 +156,6 @@ class NoteImporter(Importer): updateLog.append(updateLogTxt % fld0) dupeCount += 1 found = True - break elif self.importMode == 1: dupeCount += 1 elif self.importMode == 2: From 083d9e8aa5d041475ea59ccd54c0014afda33f54 Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Wed, 25 Jun 2014 13:46:21 -0500 Subject: [PATCH 05/11] remove search text when ctrl-clicking a left panel item --- aqt/browser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aqt/browser.py b/aqt/browser.py index e43a58a60..4a65ea9b1 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -790,8 +790,9 @@ by clicking on one on the left.""")) txt = "-"+txt if self.mw.app.keyboardModifiers() & Qt.ControlModifier: cur = unicode(self.form.searchEdit.lineEdit().text()) - if cur: - txt = cur + " " + txt + if cur and cur != \ + _(""): + txt = cur + " " + txt elif self.mw.app.keyboardModifiers() & Qt.ShiftModifier: cur = unicode(self.form.searchEdit.lineEdit().text()) if cur: From 46a38f843efd5ac37f1779ce9a24d30acd1b7035 Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Thu, 26 Jun 2014 10:07:58 -0500 Subject: [PATCH 06/11] fix rounding of cards/minute; use 1 decimal place --- anki/stats.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/anki/stats.py b/anki/stats.py index 681157785..391fa67a2 100644 --- a/anki/stats.py +++ b/anki/stats.py @@ -353,7 +353,11 @@ group by day order by day""" % (self._limit(), lim), tot, period, unit)) if total and tot: perMin = total / float(tot) - perMin = ngettext("%d card/minute", "%d cards/minute", perMin) % round(perMin) + perMin = round(perMin, 1) + perMin = ngettext("%d card/minute", "%.01f cards/minute", perMin) % perMin + # don't round down to zero + if float(perMin.split(' ')[0]) < 0.1: + perMin = ''.join(["<", _("%.01f cards/minute")]) % 0.1 self._line( i, _("Average answer time"), _("%(a)0.1fs (%(b)s)") % dict(a=(tot*60)/total, b=perMin)) From 4619933e7e47515fcd5d603c414b428c43a64d0c Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Thu, 26 Jun 2014 10:55:45 -0500 Subject: [PATCH 07/11] change default Anki folder location on Linux to Documents/Anki (leave in ~/Anki for existing installs) --- aqt/profiles.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aqt/profiles.py b/aqt/profiles.py index b0a8af646..0b456350b 100644 --- a/aqt/profiles.py +++ b/aqt/profiles.py @@ -204,7 +204,12 @@ a flash drive.""" % self.base) elif isMac: return os.path.expanduser("~/Documents/Anki") else: - return os.path.expanduser("~/Anki") + # use Documents/Anki on new installs, ~/Anki on existing ones + p = os.path.expanduser("~/Anki") + if os.path.exists(p): + return p + else: + return os.path.expanduser("~/Documents/Anki") def _loadMeta(self): path = os.path.join(self.base, "prefs.db") From 186641ad8cc8f73eeee64fe2471d1be5e5345b4d Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Sat, 28 Jun 2014 09:17:36 -0500 Subject: [PATCH 08/11] add css id to the star used for marking Can't automatically prevent the star from being affected by image resize and other CSS properties, as even weirder things happen to it when we try. However, this will give users the ability to fix it themselves. --- aqt/reviewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aqt/reviewer.py b/aqt/reviewer.py index 40a5dcdc9..9bdfc749b 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -127,7 +127,7 @@ class Reviewer(object): ########################################################################## _revHtml = """ - +