2019-02-05 04:59:03 +01:00
|
|
|
# Copyright: Ankitects Pty Ltd and contributors
|
2012-12-21 08:51:59 +01:00
|
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
2021-05-27 05:11:20 +02:00
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
2013-10-18 03:38:29 +02:00
|
|
|
from operator import itemgetter
|
2021-10-03 10:59:42 +02:00
|
|
|
from typing import Any
|
2020-07-24 04:32:57 +02:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
import aqt
|
2022-02-13 04:40:47 +01:00
|
|
|
import aqt.forms
|
2019-12-20 10:19:03 +01:00
|
|
|
from anki.consts import NEW_CARDS_RANDOM
|
2021-03-24 07:28:38 +01:00
|
|
|
from anki.decks import DeckConfigDict
|
2020-11-18 16:03:04 +01:00
|
|
|
from anki.lang import without_unicode_isolation
|
2020-02-24 13:42:30 +01:00
|
|
|
from aqt import gui_hooks
|
2019-12-20 10:19:03 +01:00
|
|
|
from aqt.qt import *
|
2019-12-23 01:34:10 +01:00
|
|
|
from aqt.utils import (
|
2021-01-25 14:45:47 +01:00
|
|
|
HelpPage,
|
2019-12-23 01:34:10 +01:00
|
|
|
askUser,
|
2021-01-07 05:24:49 +01:00
|
|
|
disable_help_button,
|
2019-12-23 01:34:10 +01:00
|
|
|
getOnlyText,
|
|
|
|
openHelp,
|
|
|
|
restoreGeom,
|
|
|
|
saveGeom,
|
|
|
|
showInfo,
|
|
|
|
showWarning,
|
|
|
|
tooltip,
|
2020-11-17 08:42:43 +01:00
|
|
|
tr,
|
2019-12-23 01:34:10 +01:00
|
|
|
)
|
2019-12-20 10:19:03 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
|
|
|
|
class DeckConf(QDialog):
|
2021-10-03 10:59:42 +02:00
|
|
|
def __init__(self, mw: aqt.AnkiQt, deck: dict) -> None:
|
2012-12-21 08:51:59 +01:00
|
|
|
QDialog.__init__(self, mw)
|
|
|
|
self.mw = mw
|
|
|
|
self.deck = deck
|
2019-12-23 01:34:10 +01:00
|
|
|
self.childDids = [d[1] for d in self.mw.col.decks.children(self.deck["id"])]
|
2013-05-18 11:17:58 +02:00
|
|
|
self._origNewOrder = None
|
2012-12-21 08:51:59 +01:00
|
|
|
self.form = aqt.forms.dconf.Ui_Dialog()
|
|
|
|
self.form.setupUi(self)
|
2020-02-24 15:29:23 +01:00
|
|
|
gui_hooks.deck_conf_did_setup_ui_form(self)
|
2021-03-26 04:48:26 +01:00
|
|
|
self.mw.checkpoint(tr.actions_options())
|
2012-12-21 08:51:59 +01:00
|
|
|
self.setupCombos()
|
|
|
|
self.setupConfs()
|
2021-01-25 14:45:47 +01:00
|
|
|
qconnect(
|
|
|
|
self.form.buttonBox.helpRequested, lambda: openHelp(HelpPage.DECK_OPTIONS)
|
|
|
|
)
|
2020-05-04 05:23:08 +02:00
|
|
|
qconnect(self.form.confOpts.clicked, self.confOpts)
|
|
|
|
qconnect(
|
2021-10-05 05:53:01 +02:00
|
|
|
self.form.buttonBox.button(
|
|
|
|
QDialogButtonBox.StandardButton.RestoreDefaults
|
|
|
|
).clicked,
|
2020-05-04 05:23:08 +02:00
|
|
|
self.onRestore,
|
2019-12-23 01:34:10 +01:00
|
|
|
)
|
2020-11-18 16:03:04 +01:00
|
|
|
self.setWindowTitle(
|
2021-03-26 05:21:04 +01:00
|
|
|
without_unicode_isolation(tr.actions_options_for(val=self.deck["name"]))
|
2020-11-18 16:03:04 +01:00
|
|
|
)
|
2021-01-07 05:24:49 +01:00
|
|
|
disable_help_button(self)
|
2013-05-23 04:09:54 +02:00
|
|
|
# qt doesn't size properly with altered fonts otherwise
|
2014-06-18 20:47:45 +02:00
|
|
|
restoreGeom(self, "deckconf", adjustSize=True)
|
2020-02-24 13:42:30 +01:00
|
|
|
gui_hooks.deck_conf_will_show(self)
|
2022-02-10 00:53:13 +01:00
|
|
|
self.open()
|
2014-06-18 20:47:45 +02:00
|
|
|
saveGeom(self, "deckconf")
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def setupCombos(self) -> None:
|
2012-12-21 08:51:59 +01:00
|
|
|
import anki.consts as cs
|
2019-12-23 01:34:10 +01:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
f = self.form
|
2021-10-22 12:39:49 +02:00
|
|
|
f.newOrder.addItems(list(cs.new_card_order_labels(self.mw.col).values()))
|
2020-05-04 05:23:08 +02:00
|
|
|
qconnect(f.newOrder.currentIndexChanged, self.onNewOrderChanged)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
|
|
|
# Conf list
|
|
|
|
######################################################################
|
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def setupConfs(self) -> None:
|
2020-05-04 05:23:08 +02:00
|
|
|
qconnect(self.form.dconf.currentIndexChanged, self.onConfChange)
|
2021-10-03 10:59:42 +02:00
|
|
|
self.conf: DeckConfigDict | None = None
|
2012-12-21 08:51:59 +01:00
|
|
|
self.loadConfs()
|
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def loadConfs(self) -> None:
|
2019-12-23 01:34:10 +01:00
|
|
|
current = self.deck["conf"]
|
2021-06-27 06:02:48 +02:00
|
|
|
self.confList = self.mw.col.decks.all_config()
|
2019-12-23 01:34:10 +01:00
|
|
|
self.confList.sort(key=itemgetter("name"))
|
2012-12-21 08:51:59 +01:00
|
|
|
startOn = 0
|
|
|
|
self.ignoreConfChange = True
|
|
|
|
self.form.dconf.clear()
|
|
|
|
for idx, conf in enumerate(self.confList):
|
2019-12-23 01:34:10 +01:00
|
|
|
self.form.dconf.addItem(conf["name"])
|
|
|
|
if str(conf["id"]) == str(current):
|
2012-12-21 08:51:59 +01:00
|
|
|
startOn = idx
|
|
|
|
self.ignoreConfChange = False
|
|
|
|
self.form.dconf.setCurrentIndex(startOn)
|
2013-05-18 11:17:58 +02:00
|
|
|
if self._origNewOrder is None:
|
2019-12-23 01:34:10 +01:00
|
|
|
self._origNewOrder = self.confList[startOn]["new"]["order"]
|
2012-12-21 08:51:59 +01:00
|
|
|
self.onConfChange(startOn)
|
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def confOpts(self) -> None:
|
2012-12-21 08:51:59 +01:00
|
|
|
m = QMenu(self.mw)
|
2021-03-26 04:48:26 +01:00
|
|
|
a = m.addAction(tr.actions_add())
|
2020-05-04 05:23:08 +02:00
|
|
|
qconnect(a.triggered, self.addGroup)
|
2021-03-26 04:48:26 +01:00
|
|
|
a = m.addAction(tr.actions_delete())
|
2020-05-04 05:23:08 +02:00
|
|
|
qconnect(a.triggered, self.remGroup)
|
2021-03-26 04:48:26 +01:00
|
|
|
a = m.addAction(tr.actions_rename())
|
2020-05-04 05:23:08 +02:00
|
|
|
qconnect(a.triggered, self.renameGroup)
|
2021-03-26 04:48:26 +01:00
|
|
|
a = m.addAction(tr.scheduling_set_for_all_subdecks())
|
2020-05-04 05:23:08 +02:00
|
|
|
qconnect(a.triggered, self.setChildren)
|
2012-12-21 08:51:59 +01:00
|
|
|
if not self.childDids:
|
|
|
|
a.setEnabled(False)
|
2021-10-05 02:01:45 +02:00
|
|
|
m.exec(QCursor.pos())
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2021-02-02 15:00:29 +01:00
|
|
|
def onConfChange(self, idx: int) -> None:
|
2012-12-21 08:51:59 +01:00
|
|
|
if self.ignoreConfChange:
|
|
|
|
return
|
|
|
|
if self.conf:
|
|
|
|
self.saveConf()
|
|
|
|
conf = self.confList[idx]
|
2019-12-23 01:34:10 +01:00
|
|
|
self.deck["conf"] = conf["id"]
|
2020-05-17 06:37:59 +02:00
|
|
|
self.mw.col.decks.save(self.deck)
|
2012-12-21 08:51:59 +01:00
|
|
|
self.loadConf()
|
2021-06-27 06:02:48 +02:00
|
|
|
cnt = len(self.mw.col.decks.decks_using_config(conf))
|
2013-05-16 09:50:48 +02:00
|
|
|
if cnt > 1:
|
2021-03-26 04:48:26 +01:00
|
|
|
txt = tr.scheduling_your_changes_will_affect_multiple_decks()
|
2013-05-16 09:50:48 +02:00
|
|
|
else:
|
|
|
|
txt = ""
|
|
|
|
self.form.count.setText(txt)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2020-04-20 05:15:23 +02:00
|
|
|
def addGroup(self) -> None:
|
2021-03-26 04:48:26 +01:00
|
|
|
name = getOnlyText(tr.scheduling_new_options_group_name())
|
2012-12-21 08:51:59 +01:00
|
|
|
if not name:
|
|
|
|
return
|
2020-05-22 21:24:05 +02:00
|
|
|
|
2012-12-21 08:51:59 +01:00
|
|
|
# first, save currently entered data to current conf
|
|
|
|
self.saveConf()
|
|
|
|
# then clone the conf
|
2020-04-20 05:15:23 +02:00
|
|
|
id = self.mw.col.decks.add_config_returning_id(name, clone_from=self.conf)
|
2020-05-22 21:24:05 +02:00
|
|
|
gui_hooks.deck_conf_did_add_config(self, self.deck, self.conf, name, id)
|
2012-12-21 08:51:59 +01:00
|
|
|
# set the deck to the new conf
|
2019-12-23 01:34:10 +01:00
|
|
|
self.deck["conf"] = id
|
2012-12-21 08:51:59 +01:00
|
|
|
# then reload the conf list
|
|
|
|
self.loadConfs()
|
|
|
|
|
2020-04-20 05:23:05 +02:00
|
|
|
def remGroup(self) -> None:
|
2019-12-23 01:34:10 +01:00
|
|
|
if int(self.conf["id"]) == 1:
|
2021-03-26 04:48:26 +01:00
|
|
|
showInfo(tr.scheduling_the_default_configuration_cant_be_removed(), self)
|
2012-12-21 08:51:59 +01:00
|
|
|
else:
|
2020-05-22 21:24:05 +02:00
|
|
|
gui_hooks.deck_conf_will_remove_config(self, self.deck, self.conf)
|
2021-06-27 07:12:22 +02:00
|
|
|
self.mw.col.mod_schema(check=True)
|
2020-04-03 05:54:52 +02:00
|
|
|
self.mw.col.decks.remove_config(self.conf["id"])
|
2020-04-30 00:10:29 +02:00
|
|
|
self.conf = None
|
2019-12-23 01:34:10 +01:00
|
|
|
self.deck["conf"] = 1
|
2012-12-21 08:51:59 +01:00
|
|
|
self.loadConfs()
|
|
|
|
|
2020-04-20 05:23:05 +02:00
|
|
|
def renameGroup(self) -> None:
|
2019-12-23 01:34:10 +01:00
|
|
|
old = self.conf["name"]
|
2021-03-26 04:48:26 +01:00
|
|
|
name = getOnlyText(tr.actions_new_name(), default=old)
|
2012-12-21 08:51:59 +01:00
|
|
|
if not name or name == old:
|
|
|
|
return
|
2020-05-22 21:24:05 +02:00
|
|
|
|
|
|
|
gui_hooks.deck_conf_will_rename_config(self, self.deck, self.conf, name)
|
2019-12-23 01:34:10 +01:00
|
|
|
self.conf["name"] = name
|
2020-04-20 05:17:55 +02:00
|
|
|
self.saveConf()
|
2012-12-21 08:51:59 +01:00
|
|
|
self.loadConfs()
|
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def setChildren(self) -> None:
|
2021-03-26 05:21:04 +01:00
|
|
|
if not askUser(tr.scheduling_set_all_decks_below_to(val=self.deck["name"])):
|
2012-12-21 08:51:59 +01:00
|
|
|
return
|
|
|
|
for did in self.childDids:
|
|
|
|
deck = self.mw.col.decks.get(did)
|
2019-12-23 01:34:10 +01:00
|
|
|
if deck["dyn"]:
|
2013-01-14 21:39:44 +01:00
|
|
|
continue
|
2019-12-23 01:34:10 +01:00
|
|
|
deck["conf"] = self.deck["conf"]
|
2012-12-21 08:51:59 +01:00
|
|
|
self.mw.col.decks.save(deck)
|
2021-03-26 05:21:04 +01:00
|
|
|
tooltip(tr.scheduling_deck_updated(count=len(self.childDids)))
|
2012-12-21 08:51:59 +01:00
|
|
|
|
|
|
|
# Loading
|
|
|
|
##################################################
|
|
|
|
|
2021-10-03 10:59:42 +02:00
|
|
|
def listToUser(self, l: list[Union[int, float]]) -> str:
|
2021-02-01 14:28:21 +01:00
|
|
|
def num_to_user(n: Union[int, float]) -> str:
|
2020-04-05 05:08:15 +02:00
|
|
|
if n == round(n):
|
|
|
|
return str(int(n))
|
|
|
|
else:
|
|
|
|
return str(n)
|
|
|
|
|
|
|
|
return " ".join(map(num_to_user, l))
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2021-02-02 15:00:29 +01:00
|
|
|
def parentLimText(self, type: str = "new") -> str:
|
2012-12-21 08:51:59 +01:00
|
|
|
# top level?
|
2019-12-23 01:34:10 +01:00
|
|
|
if "::" not in self.deck["name"]:
|
2012-12-21 08:51:59 +01:00
|
|
|
return ""
|
|
|
|
lim = -1
|
2019-12-23 01:34:10 +01:00
|
|
|
for d in self.mw.col.decks.parents(self.deck["id"]):
|
2021-06-27 06:02:48 +02:00
|
|
|
c = self.mw.col.decks.config_dict_for_deck_id(d["id"])
|
2019-12-23 01:34:10 +01:00
|
|
|
x = c[type]["perDay"]
|
2012-12-21 08:51:59 +01:00
|
|
|
if lim == -1:
|
|
|
|
lim = x
|
|
|
|
else:
|
|
|
|
lim = min(x, lim)
|
2021-03-26 05:21:04 +01:00
|
|
|
return tr.scheduling_parent_limit(val=lim)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def loadConf(self) -> None:
|
2021-06-27 06:02:48 +02:00
|
|
|
self.conf = self.mw.col.decks.config_dict_for_deck_id(self.deck["id"])
|
2012-12-21 08:51:59 +01:00
|
|
|
# new
|
2019-12-23 01:34:10 +01:00
|
|
|
c = self.conf["new"]
|
2012-12-21 08:51:59 +01:00
|
|
|
f = self.form
|
2019-12-23 01:34:10 +01:00
|
|
|
f.lrnSteps.setText(self.listToUser(c["delays"]))
|
|
|
|
f.lrnGradInt.setValue(c["ints"][0])
|
|
|
|
f.lrnEasyInt.setValue(c["ints"][1])
|
2022-02-11 01:59:04 +01:00
|
|
|
f.lrnFactor.setValue(int(c["initialFactor"] / 10.0))
|
2019-12-23 01:34:10 +01:00
|
|
|
f.newOrder.setCurrentIndex(c["order"])
|
|
|
|
f.newPerDay.setValue(c["perDay"])
|
rework sibling handling and change bury semantics
First, burying changes:
- unburying now happens on day rollover, or when manually unburying from
overview screen
- burying is not performed when returning to deck list, or when closing
collection, so burying now must mark cards as modified to ensure sync
consistent
- because they're no longer temporary to a session, make sure we exclude them
in filtered decks in -is:suspended
Sibling spacing changes:
- core behaviour now based on automatically burying related cards when we
answer a card
- applies to reviews, optionally to new cards, and never to cards in the
learning queue (partly because we can't suspend/bury cards in that queue at
the moment)
- this means spacing works consistently in filtered decks now, works on
reviews even when user is late to review, and provides better separation of
new cards
- if burying new cards disabled, we just discard them from the current queue.
an option to set due=ord*space+due would be nicer, but would require
changing a lot of code and is more appropriate for a future major version
change. discarding from queue suffers from the same issue as the new card
cycling in that queue rebuilds may cause cards to be shown close together,
so the default burying behaviour is preferable
- refer to them as 'related cards' rather than 'siblings'
These changes don't require any changes to the database format, so they
should hopefully coexist with older clients without issue.
2013-08-10 08:54:33 +02:00
|
|
|
f.bury.setChecked(c.get("bury", True))
|
2019-12-23 01:34:10 +01:00
|
|
|
f.newplim.setText(self.parentLimText("new"))
|
2012-12-21 08:51:59 +01:00
|
|
|
# rev
|
2019-12-23 01:34:10 +01:00
|
|
|
c = self.conf["rev"]
|
|
|
|
f.revPerDay.setValue(c["perDay"])
|
2022-02-11 01:59:04 +01:00
|
|
|
f.easyBonus.setValue(int(c["ease4"] * 100))
|
2019-12-23 01:34:10 +01:00
|
|
|
f.fi1.setValue(c["ivlFct"] * 100)
|
|
|
|
f.maxIvl.setValue(c["maxIvl"])
|
|
|
|
f.revplim.setText(self.parentLimText("rev"))
|
2013-10-18 03:38:29 +02:00
|
|
|
f.buryRev.setChecked(c.get("bury", True))
|
2019-12-23 01:34:10 +01:00
|
|
|
f.hardFactor.setValue(int(c.get("hardFactor", 1.2) * 100))
|
2021-06-27 07:12:22 +02:00
|
|
|
if self.mw.col.sched_ver() == 1:
|
2018-07-11 13:23:22 +02:00
|
|
|
f.hardFactor.setVisible(False)
|
|
|
|
f.hardFactorLabel.setVisible(False)
|
2012-12-21 08:51:59 +01:00
|
|
|
# lapse
|
2019-12-23 01:34:10 +01:00
|
|
|
c = self.conf["lapse"]
|
|
|
|
f.lapSteps.setText(self.listToUser(c["delays"]))
|
2022-02-11 01:59:04 +01:00
|
|
|
f.lapMult.setValue(int(c["mult"] * 100))
|
2019-12-23 01:34:10 +01:00
|
|
|
f.lapMinInt.setValue(c["minInt"])
|
|
|
|
f.leechThreshold.setValue(c["leechFails"])
|
|
|
|
f.leechAction.setCurrentIndex(c["leechAction"])
|
2012-12-21 08:51:59 +01:00
|
|
|
# general
|
|
|
|
c = self.conf
|
2019-12-23 01:34:10 +01:00
|
|
|
f.maxTaken.setValue(c["maxTaken"])
|
|
|
|
f.showTimer.setChecked(c.get("timer", 0))
|
|
|
|
f.autoplaySounds.setChecked(c["autoplay"])
|
|
|
|
f.replayQuestion.setChecked(c.get("replayq", True))
|
2020-02-24 15:47:48 +01:00
|
|
|
gui_hooks.deck_conf_did_load_config(self, self.deck, self.conf)
|
2012-12-21 08:51:59 +01:00
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def onRestore(self) -> None:
|
2012-12-21 08:51:59 +01:00
|
|
|
self.mw.progress.start()
|
2021-06-27 06:02:48 +02:00
|
|
|
self.mw.col.decks.restore_to_default(self.conf)
|
2012-12-21 08:51:59 +01:00
|
|
|
self.mw.progress.finish()
|
|
|
|
self.loadConf()
|
|
|
|
|
|
|
|
# New order
|
|
|
|
##################################################
|
|
|
|
|
2021-02-02 15:00:29 +01:00
|
|
|
def onNewOrderChanged(self, new: bool) -> None:
|
2019-12-23 01:34:10 +01:00
|
|
|
old = self.conf["new"]["order"]
|
2012-12-21 08:51:59 +01:00
|
|
|
if old == new:
|
|
|
|
return
|
2019-12-23 01:34:10 +01:00
|
|
|
self.conf["new"]["order"] = new
|
2012-12-21 08:51:59 +01:00
|
|
|
self.mw.progress.start()
|
2021-10-22 12:39:49 +02:00
|
|
|
self.mw.col.sched.resort_conf(self.conf)
|
2012-12-21 08:51:59 +01:00
|
|
|
self.mw.progress.finish()
|
|
|
|
|
|
|
|
# Saving
|
|
|
|
##################################################
|
|
|
|
|
2020-07-24 04:32:57 +02:00
|
|
|
def updateList(self, conf: Any, key: str, w: QLineEdit, minSize: int = 1) -> None:
|
2016-05-12 06:45:35 +02:00
|
|
|
items = str(w.text()).split(" ")
|
2012-12-21 08:51:59 +01:00
|
|
|
ret = []
|
2020-07-24 04:32:57 +02:00
|
|
|
for item in items:
|
|
|
|
if not item:
|
2012-12-21 08:51:59 +01:00
|
|
|
continue
|
|
|
|
try:
|
2020-07-24 04:32:57 +02:00
|
|
|
i = float(item)
|
Move away from Bazel (#2202)
(for upgrading users, please see the notes at the bottom)
Bazel brought a lot of nice things to the table, such as rebuilds based on
content changes instead of modification times, caching of build products,
detection of incorrect build rules via a sandbox, and so on. Rewriting the build
in Bazel was also an opportunity to improve on the Makefile-based build we had
prior, which was pretty poor: most dependencies were external or not pinned, and
the build graph was poorly defined and mostly serialized. It was not uncommon
for fresh checkouts to fail due to floating dependencies, or for things to break
when trying to switch to an older commit.
For day-to-day development, I think Bazel served us reasonably well - we could
generally switch between branches while being confident that builds would be
correct and reasonably fast, and not require full rebuilds (except on Windows,
where the lack of a sandbox and the TS rules would cause build breakages when TS
files were renamed/removed).
Bazel achieves that reliability by defining rules for each programming language
that define how source files should be turned into outputs. For the rules to
work with Bazel's sandboxing approach, they often have to reimplement or
partially bypass the standard tools that each programming language provides. The
Rust rules call Rust's compiler directly for example, instead of using Cargo,
and the Python rules extract each PyPi package into a separate folder that gets
added to sys.path.
These separate language rules allow proper declaration of inputs and outputs,
and offer some advantages such as caching of build products and fine-grained
dependency installation. But they also bring some downsides:
- The rules don't always support use-cases/platforms that the standard language
tools do, meaning they need to be patched to be used. I've had to contribute a
number of patches to the Rust, Python and JS rules to unblock various issues.
- The dependencies we use with each language sometimes make assumptions that do
not hold in Bazel, meaning they either need to be pinned or patched, or the
language rules need to be adjusted to accommodate them.
I was hopeful that after the initial setup work, things would be relatively
smooth-sailing. Unfortunately, that has not proved to be the case. Things
frequently broke when dependencies or the language rules were updated, and I
began to get frustrated at the amount of Anki development time I was instead
spending on build system upkeep. It's now about 2 years since switching to
Bazel, and I think it's time to cut losses, and switch to something else that's
a better fit.
The new build system is based on a small build tool called Ninja, and some
custom Rust code in build/. This means that to build Anki, Bazel is no longer
required, but Ninja and Rust need to be installed on your system. Python and
Node toolchains are automatically downloaded like in Bazel.
This new build system should result in faster builds in some cases:
- Because we're using cargo to build now, Rust builds are able to take advantage
of pipelining and incremental debug builds, which we didn't have with Bazel.
It's also easier to override the default linker on Linux/macOS, which can
further improve speeds.
- External Rust crates are now built with opt=1, which improves performance
of debug builds.
- Esbuild is now used to transpile TypeScript, instead of invoking the TypeScript
compiler. This results in faster builds, by deferring typechecking to test/check
time, and by allowing more work to happen in parallel.
As an example of the differences, when testing with the mold linker on Linux,
adding a new message to tags.proto (which triggers a recompile of the bulk of
the Rust and TypeScript code) results in a compile that goes from about 22s on
Bazel to about 7s in the new system. With the standard linker, it's about 9s.
Some other changes of note:
- Our Rust workspace now uses cargo-hakari to ensure all packages agree on
available features, preventing unnecessary rebuilds.
- pylib/anki is now a PEP420 implicit namespace, avoiding the need to merge
source files and generated files into a single folder for running. By telling
VSCode about the extra search path, code completion now works with generated
files without needing to symlink them into the source folder.
- qt/aqt can't use PEP420 as it's difficult to get rid of aqt/__init__.py.
Instead, the generated files are now placed in a separate _aqt package that's
added to the path.
- ts/lib is now exposed as @tslib, so the source code and generated code can be
provided under the same namespace without a merging step.
- MyPy and PyLint are now invoked once for the entire codebase.
- dprint will be used to format TypeScript/json files in the future instead of
the slower prettier (currently turned off to avoid causing conflicts). It can
automatically defer to prettier when formatting Svelte files.
- svelte-check is now used for typechecking our Svelte code, which revealed a
few typing issues that went undetected with the old system.
- The Jest unit tests now work on Windows as well.
If you're upgrading from Bazel, updated usage instructions are in docs/development.md and docs/build.md. A summary of the changes:
- please remove node_modules and .bazel
- install rustup (https://rustup.rs/)
- install rsync if not already installed (on windows, use pacman - see docs/windows.md)
- install Ninja (unzip from https://github.com/ninja-build/ninja/releases/tag/v1.11.1 and
place on your path, or from your distro/homebrew if it's 1.10+)
- update .vscode/settings.json from .vscode.dist
2022-11-27 06:24:20 +01:00
|
|
|
if i <= 0:
|
2021-11-25 08:47:50 +01:00
|
|
|
raise Exception("0 invalid")
|
2012-12-21 08:51:59 +01:00
|
|
|
if i == int(i):
|
|
|
|
i = int(i)
|
|
|
|
ret.append(i)
|
|
|
|
except:
|
|
|
|
# invalid, don't update
|
2021-03-26 04:48:26 +01:00
|
|
|
showWarning(tr.scheduling_steps_must_be_numbers())
|
2012-12-21 08:51:59 +01:00
|
|
|
return
|
|
|
|
if len(ret) < minSize:
|
2021-03-26 04:48:26 +01:00
|
|
|
showWarning(tr.scheduling_at_least_one_step_is_required())
|
2012-12-21 08:51:59 +01:00
|
|
|
return
|
|
|
|
conf[key] = ret
|
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def saveConf(self) -> None:
|
2012-12-21 08:51:59 +01:00
|
|
|
# new
|
2019-12-23 01:34:10 +01:00
|
|
|
c = self.conf["new"]
|
2012-12-21 08:51:59 +01:00
|
|
|
f = self.form
|
2019-12-23 01:34:10 +01:00
|
|
|
self.updateList(c, "delays", f.lrnSteps)
|
|
|
|
c["ints"][0] = f.lrnGradInt.value()
|
|
|
|
c["ints"][1] = f.lrnEasyInt.value()
|
|
|
|
c["initialFactor"] = f.lrnFactor.value() * 10
|
|
|
|
c["order"] = f.newOrder.currentIndex()
|
|
|
|
c["perDay"] = f.newPerDay.value()
|
|
|
|
c["bury"] = f.bury.isChecked()
|
|
|
|
if self._origNewOrder != c["order"]:
|
2013-05-18 11:17:58 +02:00
|
|
|
# order of current deck has changed, so have to resort
|
2019-12-23 01:34:10 +01:00
|
|
|
if c["order"] == NEW_CARDS_RANDOM:
|
2021-10-22 12:39:49 +02:00
|
|
|
self.mw.col.sched.randomize_cards(self.deck["id"])
|
2013-05-18 11:17:58 +02:00
|
|
|
else:
|
2021-10-22 12:39:49 +02:00
|
|
|
self.mw.col.sched.order_cards(self.deck["id"])
|
2012-12-21 08:51:59 +01:00
|
|
|
# rev
|
2019-12-23 01:34:10 +01:00
|
|
|
c = self.conf["rev"]
|
|
|
|
c["perDay"] = f.revPerDay.value()
|
|
|
|
c["ease4"] = f.easyBonus.value() / 100.0
|
|
|
|
c["ivlFct"] = f.fi1.value() / 100.0
|
|
|
|
c["maxIvl"] = f.maxIvl.value()
|
|
|
|
c["bury"] = f.buryRev.isChecked()
|
|
|
|
c["hardFactor"] = f.hardFactor.value() / 100.0
|
2012-12-21 08:51:59 +01:00
|
|
|
# lapse
|
2019-12-23 01:34:10 +01:00
|
|
|
c = self.conf["lapse"]
|
|
|
|
self.updateList(c, "delays", f.lapSteps, minSize=0)
|
|
|
|
c["mult"] = f.lapMult.value() / 100.0
|
|
|
|
c["minInt"] = f.lapMinInt.value()
|
|
|
|
c["leechFails"] = f.leechThreshold.value()
|
|
|
|
c["leechAction"] = f.leechAction.currentIndex()
|
2012-12-21 08:51:59 +01:00
|
|
|
# general
|
|
|
|
c = self.conf
|
2019-12-23 01:34:10 +01:00
|
|
|
c["maxTaken"] = f.maxTaken.value()
|
|
|
|
c["timer"] = f.showTimer.isChecked() and 1 or 0
|
|
|
|
c["autoplay"] = f.autoplaySounds.isChecked()
|
|
|
|
c["replayq"] = f.replayQuestion.isChecked()
|
2020-02-24 13:42:30 +01:00
|
|
|
gui_hooks.deck_conf_will_save_config(self, self.deck, self.conf)
|
2012-12-21 08:51:59 +01:00
|
|
|
self.mw.col.decks.save(self.deck)
|
|
|
|
self.mw.col.decks.save(self.conf)
|
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def reject(self) -> None:
|
2012-12-21 08:51:59 +01:00
|
|
|
self.accept()
|
|
|
|
|
2021-02-01 14:28:21 +01:00
|
|
|
def accept(self) -> None:
|
2012-12-21 08:51:59 +01:00
|
|
|
self.saveConf()
|
|
|
|
self.mw.reset()
|
|
|
|
QDialog.accept(self)
|