mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
restore custom colour palette on editor init
This commit is contained in:
parent
2e466285f0
commit
ed7228af30
1 changed files with 13 additions and 0 deletions
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue