add SaveCustomColours rpc method

This commit is contained in:
llama 2025-09-10 00:29:38 +08:00
parent 539054c34d
commit 2e466285f0
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3
2 changed files with 16 additions and 0 deletions

View file

@ -27,6 +27,9 @@ service FrontendService {
rpc deckOptionsRequireClose(generic.Empty) returns (generic.Empty);
// Warns python that the deck option web view is ready to receive requests.
rpc deckOptionsReady(generic.Empty) returns (generic.Empty);
// Save colour picker's custom colour palette
rpc SaveCustomColours(generic.Empty) returns (generic.Empty);
}
service BackendFrontendService {}

View file

@ -599,6 +599,18 @@ def deck_options_ready() -> bytes:
return b""
def save_custom_colours() -> bytes:
colours = ",".join(
[
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
return b""
post_handler_list = [
congrats_info,
get_deck_configs_for_update,
@ -614,6 +626,7 @@ post_handler_list = [
search_in_browser,
deck_options_require_close,
deck_options_ready,
save_custom_colours,
]