mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Store colors in the collection
One minor tweak to the logic while I was there: an invalid color no longer invalidates all the rest.
This commit is contained in:
parent
1df93b02f8
commit
321b21d6a0
2 changed files with 11 additions and 18 deletions
|
@ -351,15 +351,11 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
|
|||
QShortcut(QKeySequence(keys), self.widget, activated=fn) # type: ignore
|
||||
|
||||
def setupColourPalette(self) -> None:
|
||||
assert self.mw.pm.profile is not None
|
||||
if custom_colours := str(
|
||||
self.mw.pm.profile.get("customColorPickerPalette", "")
|
||||
):
|
||||
for i, colour in enumerate(
|
||||
custom_colours.split(",")[: QColorDialog.customCount()]
|
||||
):
|
||||
if not (colors := self.mw.col.get_config("customColorPickerPalette")):
|
||||
return
|
||||
for i, colour in enumerate(colors[: QColorDialog.customCount()]):
|
||||
if not QColor.isValidColorName(colour):
|
||||
break
|
||||
continue
|
||||
QColorDialog.setCustomColor(i, QColor.fromString(colour))
|
||||
|
||||
def _addFocusCheck(self, fn: Callable) -> Callable:
|
||||
|
|
|
@ -600,14 +600,11 @@ def deck_options_ready() -> bytes:
|
|||
|
||||
|
||||
def save_custom_colours() -> bytes:
|
||||
colours = ",".join(
|
||||
[
|
||||
colors = [
|
||||
QColorDialog.customColor(i).name(QColor.NameFormat.HexArgb)
|
||||
for i in range(QColorDialog.customCount())
|
||||
]
|
||||
)
|
||||
assert aqt.mw.pm.profile is not None
|
||||
aqt.mw.pm.profile["customColorPickerPalette"] = colours
|
||||
aqt.mw.col.set_config("customColorPickerPalette", colors)
|
||||
return b""
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue