From 131d37dca52c29033432e0149052093ab1c79461 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 10 Mar 2020 17:50:18 +1000 Subject: [PATCH] add switch in prefs for new timezone handling code; bump sync version AD devs: before updating the sync version to 10, please make sure the new timezone code has been ported over. The core change to the scheduler is in _updateCutoff(): https://github.com/ankitects/anki/blob/9736e4a970df9b67776282cde083a7b007061e87/pylib/anki/schedv2.py#L1357 with the following supporting Python functions: https://github.com/ankitects/anki/blob/9736e4a970df9b67776282cde083a7b007061e87/pylib/anki/schedv2.py#L1410 _timing_today() is calculated in Rust (lines up to 92, the rest are tests): https://github.com/ankitects/anki/blob/9736e4a970df9b67776282cde083a7b007061e87/rslib/src/sched/cutoff.rs#L20 The change went through a few iterations before stabilising, so it's probably easier to refer to the above code than the patches that got us to that point. --- pylib/anki/consts.py | 2 +- qt/aqt/preferences.py | 10 ++++++++++ qt/designer/preferences.ui | 11 ++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pylib/anki/consts.py b/pylib/anki/consts.py index 786e4b17bf1..921a1a70211 100644 --- a/pylib/anki/consts.py +++ b/pylib/anki/consts.py @@ -71,7 +71,7 @@ SYNC_ZIP_SIZE = int(2.5 * 1024 * 1024) SYNC_ZIP_COUNT = 25 SYNC_BASE = "https://sync%s.ankiweb.net/" -SYNC_VER = 9 +SYNC_VER = 10 HELP_SITE = "https://apps.ankiweb.net/docs/manual.html" diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index ecfbe64cf4f..d59493cc729 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -92,8 +92,10 @@ def setupCollection(self): f.dayLearnFirst.setChecked(qc.get("dayLearnFirst", False)) if self.mw.col.schedVer() != 2: f.dayLearnFirst.setVisible(False) + f.new_timezone.setVisible(False) else: f.newSched.setChecked(True) + f.new_timezone.setChecked(self.mw.col.sched._new_timezone_enabled()) def updateCollection(self): f = self.form @@ -118,6 +120,14 @@ def updateCollection(self): qc["addToCur"] = not f.useCurrent.currentIndex() qc["dayLearnFirst"] = f.dayLearnFirst.isChecked() self._updateDayCutoff() + if self.mw.col.schedVer() != 1: + was_enabled = self.mw.col.sched._new_timezone_enabled() + is_enabled = f.new_timezone.isChecked() + if was_enabled != is_enabled: + if is_enabled: + self.mw.col.sched.set_creation_offset() + else: + self.mw.col.sched.clear_creation_offset() self._updateSchedVer(f.newSched.isChecked()) d.setMod() diff --git a/qt/designer/preferences.ui b/qt/designer/preferences.ui index 03ec7d8eb24..76ac79e4b53 100644 --- a/qt/designer/preferences.ui +++ b/qt/designer/preferences.ui @@ -7,7 +7,7 @@ 0 0 422 - 611 + 636 @@ -136,6 +136,13 @@ + + + + New timezone handling (not yet supported by AnkiDroid) + + + @@ -559,6 +566,7 @@ nightMode dayLearnFirst newSched + new_timezone useCurrent newSpread uiScale @@ -571,6 +579,7 @@ syncOnProgramOpen fullSync syncDeauth + media_log