mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Add function to restore the default name of a flag
This commit is contained in:
parent
fab939e0e1
commit
957d749f1c
1 changed files with 18 additions and 0 deletions
|
@ -35,6 +35,15 @@ class FlagManager:
|
||||||
def __init__(self, mw: aqt.main.AnkiQt) -> None:
|
def __init__(self, mw: aqt.main.AnkiQt) -> None:
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self._flags: list[Flag] = []
|
self._flags: list[Flag] = []
|
||||||
|
self.default_flag_names: dict[int, str] = {
|
||||||
|
1: tr.actions_flag_red(),
|
||||||
|
2: tr.actions_flag_orange(),
|
||||||
|
3: tr.actions_flag_green(),
|
||||||
|
4: tr.actions_flag_blue(),
|
||||||
|
5: tr.actions_flag_pink(),
|
||||||
|
6: tr.actions_flag_turquoise(),
|
||||||
|
7: tr.actions_flag_purple()
|
||||||
|
}
|
||||||
|
|
||||||
def all(self) -> list[Flag]:
|
def all(self) -> list[Flag]:
|
||||||
"""Return a list of all flags."""
|
"""Return a list of all flags."""
|
||||||
|
@ -55,6 +64,15 @@ class FlagManager:
|
||||||
self.mw.col.set_config("flagLabels", labels)
|
self.mw.col.set_config("flagLabels", labels)
|
||||||
gui_hooks.flag_label_did_change()
|
gui_hooks.flag_label_did_change()
|
||||||
|
|
||||||
|
def restore_default_flag_name(self, flag_index: int) -> None:
|
||||||
|
labels = self.mw.col.get_config("flagLabels", {})
|
||||||
|
if str(flag_index) not in labels:
|
||||||
|
return
|
||||||
|
del labels[str(flag_index)]
|
||||||
|
self.get_flag(flag_index).label = self.default_flag_names[flag_index]
|
||||||
|
self.mw.col.set_config("flagLabels", labels)
|
||||||
|
gui_hooks.flag_label_did_change()
|
||||||
|
|
||||||
def require_refresh(self) -> None:
|
def require_refresh(self) -> None:
|
||||||
"Discard cached labels."
|
"Discard cached labels."
|
||||||
self._flags = []
|
self._flags = []
|
||||||
|
|
Loading…
Reference in a new issue