restore custom colour palette on editor init

This commit is contained in:
llama 2025-09-10 00:30:18 +08:00
parent 2e466285f0
commit ed7228af30
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3

View file

@ -151,6 +151,7 @@ class Editor:
self.add_webview() self.add_webview()
self.setupWeb() self.setupWeb()
self.setupShortcuts() self.setupShortcuts()
self.setupColourPalette()
gui_hooks.editor_did_init(self) gui_hooks.editor_did_init(self)
# Initial setup # Initial setup
@ -349,6 +350,18 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
keys, fn, _ = row keys, fn, _ = row
QShortcut(QKeySequence(keys), self.widget, activated=fn) # type: ignore 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 QColor.isValidColorName(colour):
break
QColorDialog.setCustomColor(i, QColor.fromString(colour))
def _addFocusCheck(self, fn: Callable) -> Callable: def _addFocusCheck(self, fn: Callable) -> Callable:
def checkFocus() -> None: def checkFocus() -> None:
if self.currentField is None: if self.currentField is None: