mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
support customizing day cutoff w/ V2 scheduler
This commit is contained in:
parent
651b107b18
commit
b17a0552d0
1 changed files with 35 additions and 5 deletions
|
@ -74,8 +74,7 @@ class Preferences(QDialog):
|
||||||
import anki.consts as c
|
import anki.consts as c
|
||||||
f = self.form
|
f = self.form
|
||||||
qc = self.mw.col.conf
|
qc = self.mw.col.conf
|
||||||
self.startDate = datetime.datetime.fromtimestamp(self.mw.col.crt)
|
self._setupDayCutoff()
|
||||||
f.dayOffset.setValue(self.startDate.hour)
|
|
||||||
f.lrnCutoff.setValue(qc['collapseTime']/60.0)
|
f.lrnCutoff.setValue(qc['collapseTime']/60.0)
|
||||||
f.timeLimit.setValue(qc['timeLim']/60.0)
|
f.timeLimit.setValue(qc['timeLim']/60.0)
|
||||||
f.showEstimates.setChecked(qc['estTimes'])
|
f.showEstimates.setChecked(qc['estTimes'])
|
||||||
|
@ -85,6 +84,8 @@ class Preferences(QDialog):
|
||||||
f.newSpread.setCurrentIndex(qc['newSpread'])
|
f.newSpread.setCurrentIndex(qc['newSpread'])
|
||||||
f.useCurrent.setCurrentIndex(int(not qc.get("addToCur", True)))
|
f.useCurrent.setCurrentIndex(int(not qc.get("addToCur", True)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def updateCollection(self):
|
def updateCollection(self):
|
||||||
f = self.form
|
f = self.form
|
||||||
d = self.mw.col
|
d = self.mw.col
|
||||||
|
@ -96,12 +97,41 @@ class Preferences(QDialog):
|
||||||
qc['timeLim'] = f.timeLimit.value()*60
|
qc['timeLim'] = f.timeLimit.value()*60
|
||||||
qc['collapseTime'] = f.lrnCutoff.value()*60
|
qc['collapseTime'] = f.lrnCutoff.value()*60
|
||||||
qc['addToCur'] = not f.useCurrent.currentIndex()
|
qc['addToCur'] = not f.useCurrent.currentIndex()
|
||||||
hrs = f.dayOffset.value()
|
self._updateDayCutoff()
|
||||||
|
d.setMod()
|
||||||
|
|
||||||
|
# Day cutoff
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
def _setupDayCutoff(self):
|
||||||
|
if self.mw.col.schedVer() == 2:
|
||||||
|
self._setupDayCutoffV2()
|
||||||
|
else:
|
||||||
|
self._setupDayCutoffV1()
|
||||||
|
|
||||||
|
|
||||||
|
def _setupDayCutoffV1(self):
|
||||||
|
self.startDate = datetime.datetime.fromtimestamp(self.mw.col.crt)
|
||||||
|
self.form.dayOffset.setValue(self.startDate.hour)
|
||||||
|
|
||||||
|
def _setupDayCutoffV2(self):
|
||||||
|
self.form.dayOffset.setValue(self.mw.col.conf.get("rollover", 4))
|
||||||
|
|
||||||
|
def _updateDayCutoff(self):
|
||||||
|
if self.mw.col.schedVer() == 2:
|
||||||
|
self._updateDayCutoffV2()
|
||||||
|
else:
|
||||||
|
self._updateDayCutoffV1()
|
||||||
|
|
||||||
|
def _updateDayCutoffV1(self):
|
||||||
|
hrs = self.form.dayOffset.value()
|
||||||
old = self.startDate
|
old = self.startDate
|
||||||
date = datetime.datetime(
|
date = datetime.datetime(
|
||||||
old.year, old.month, old.day, hrs)
|
old.year, old.month, old.day, hrs)
|
||||||
d.crt = int(time.mktime(date.timetuple()))
|
self.mw.col.crt = int(time.mktime(date.timetuple()))
|
||||||
d.setMod()
|
|
||||||
|
def _updateDayCutoffV2(self):
|
||||||
|
self.mw.col.conf['rollover'] = self.form.dayOffset.value()
|
||||||
|
|
||||||
# Network
|
# Network
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue