AnKing-VIP / AnkiRecolor

Recolor addon commissioned by and created for AnKing
38 stars 6 forks source link

2.1.55 error #19

Closed AnKingMed closed 1 year ago

AnKingMed commented 1 year ago

Caught exception:
Traceback (most recent call last):
 File "/Users/Nick/Library/Application Support/Anki2/addons21/ReColor/ankiaddonconfig/window.py", line 105, in on_save
 hook()
 File "/Users/Nick/Library/Application Support/Anki2/addons21/ReColor/config.py", line 57, in on_save
 recolor_web()
 File "/Users/Nick/Library/Application Support/Anki2/addons21/ReColor/colors.py", line 80, in recolor_web
 update_webview_css(webview)
 File "/Users/Nick/Library/Application Support/Anki2/addons21/ReColor/colors.py", line 84, in update_webview_css
 (light_mode_css, dark_mode_css) = get_theme_css()
 File "/Users/Nick/Library/Application Support/Anki2/addons21/ReColor/colors.py", line 54, in get_theme_css
 css_names = entry[3]
KeyError: 3

I also noticed the fastbar doesn't change color. I don't know if that's possible, but wanted to mention it.

AnKingMed commented 1 year ago

@BlueGreenMagick

BlueGreenMagick commented 1 year ago

Could you copy paste your add-on config?

AnKingMed commented 1 year ago

{
 "colors": {
 "ACCENT_CARD": [
 "Card mode",
 "#60a5fa",
 "#93c5fd",
 "--accent-card"
 ],
 "ACCENT_DANGER": [
 "Danger",
 "#ef4444",
 "#f87171",
 "--accent-danger"
 ],
 "ACCENT_NOTE": [
 "Note mode",
 "#22c55e",
 "#4ade80",
 "--accent-note"
 ],
 "BORDER": [
 "Border",
 "#D8DEE9",
 "#575268",
 "--border"
 ],
 "BORDER_FOCUS": [
 "Border (focused input)",
 "#3b82f6",
 "#3b82f6",
 "--border-focus"
 ],
 "BORDER_STRONG": [
 "Border (strong)",
 "#858585",
 "#020202",
 "--border-strong"
 ],
 "BORDER_SUBTLE": [
 "Border (subtle)",
 "#ECEFF4",
 "#27987f",
 "--border-subtle"
 ],
 "BURIED_FG": {
 "2": "#302D41"
 },
 "BUTTON_BG": [
 "Button background",
 "#D8DEE9",
 "#1E1E2E",
 "--button-bg"
 ],
 "BUTTON_DISABLED": [
 "Button background (disabled)",
 "#d6d6d680",
 "#45454580",
 "--button-disabled"
 ],
 "BUTTON_HOVER": [
 "Button background (hover)",
 "#E5E9F0",
 "#0a2833",
 [
 "--button-gradient-start",
 "--button-gradient-end"
 ]
 ],
 "BUTTON_HOVER_BORDER": [
 "Button border (hover)",
 "#999999",
 "#141414",
 "--button-hover-border"
 ],
 "BUTTON_PRIMARY_BG": [
 "Button Primary Bg",
 "#60a5fa",
 "#2f67e1",
 "--button-primary-bg"
 ],
 "BUTTON_PRIMARY_DISABLED": [
 "Button Primary Disabled",
 "#93c5fd",
 "#4484ed",
 "--button-primary-disabled"
 ],
 "BUTTON_PRIMARY_GRADIENT_END": [
 "Button Primary Gradient End",
 "#2563eb",
 "#2544a8",
 "--button-primary-gradient-end"
 ],
 "BUTTON_PRIMARY_GRADIENT_START": [
 "Button Primary Gradient Start",
 "#60a5fa",
 "#2f67e1",
 "--button-primary-gradient-start"
 ],
 "CANVAS": [
 "Background",
 "white",
 "#032029",
 "--canvas"
 ],
 "CANVAS_CODE": [
 "Code editor background",
 "#eeeeee",
 "#252525",
 "--canvas-code"
 ],
 "CANVAS_ELEVATED": [
 "Background (elevated)",
 "#E5E9F0",
 "#0a2833",
 "--canvas-elevated"
 ],
 "CANVAS_INSET": [
 "Background (inset)",
 "#E5E9F0",
 "#0a2833",
 "--canvas-inset"
 ],
 "CANVAS_OVERLAY": [
 "Background (menu & tooltip)",
 "white",
 "#032029",
 "--canvas-overlay"
 ],
 "CURRENT_DECK": {
 "2": "#302D41"
 },
 "DISABLED": {
 "2": "#F8BD96"
 },
 "FAINT_BORDER": {
 "2": "#1E1E2E"
 },
 "FG": [
 "Text",
 "#2E3440",
 "#fdf4dd",
 "--fg"
 ],
 "FG_DISABLED": [
 "Text (disabled)",
 "#D8DEE9",
 "#008c6a",
 "--fg-disabled"
 ],
 "FG_FAINT": [
 "Text (faint)",
 "#D8DEE9",
 "#eae3cc",
 "--fg-faint"
 ],
 "FG_LINK": [
 "Text (link)",
 "#8FBCBB",
 "#2076c9",
 "--fg-link"
 ],
 "FG_SUBTLE": [
 "Text (subtle)",
 "#3B4252",
 "#858585",
 "--fg-subtle"
 ],
 "FLAG1_BG": {
 "2": "#F28FAD"
 },
 "FLAG1_FG": {
 "2": "#F28FAD"
 },
 "FLAG2_BG": {
 "2": "#F8BD96"
 },
 "FLAG2_FG": {
 "2": "#F8BD96"
 },
 "FLAG3_BG": {
 "2": "#ABE9B3"
 },
 "FLAG3_FG": {
 "2": "#ABE9B3"
 },
 "FLAG4_BG": {
 "2": "#96CDFB"
 },
 "FLAG4_FG": {
 "2": "#96CDFB"
 },
 "FLAG5_BG": {
 "2": "#DDB6F2"
 },
 "FLAG5_FG": {
 "2": "#DDB6F2"
 },
 "FLAG6_BG": {
 "2": "#89DCEB"
 },
 "FLAG6_FG": {
 "2": "#89DCEB"
 },
 "FLAG7_BG": {
 "2": "#C9CBFF"
 },
 "FLAG7_FG": {
 "2": "#C9CBFF"
 },
 "FLAG_1": [
 "Flag 1",
 "#BF616A",
 "#f87171",
 "--flag-1"
 ],
 "FLAG_2": [
 "Flag 2",
 "#D08770",
 "#fdba74",
 "--flag-2"
 ],
 "FLAG_3": [
 "Flag 3",
 "#A3BE8C",
 "#86efac",
 "--flag-3"
 ],
 "FLAG_4": [
 "Flag 4",
 "#5E81AC",
 "#60a5fa",
 "--flag-4"
 ],
 "FLAG_5": [
 "Flag 5",
 "#B48EAD",
 "#f0abfc",
 "--flag-5"
 ],
 "FLAG_6": [
 "Flag 6",
 "#2dd4bf",
 "#5eead4",
 "--flag-6"
 ],
 "FLAG_7": [
 "Flag 7",
 "#a855f7",
 "#c084fc",
 "--flag-7"
 ],
 "FRAME_BG": {
 "2": "#1A1826"
 },
 "HIGHLIGHT_BG": [
 "Highlight background",
 "#81A1C1",
 "#C9CBFF",
 "--highlight-bg"
 ],
 "HIGHLIGHT_FG": [
 "Highlight text",
 "black",
 "#F5E0DC",
 "--highlight-fg"
 ],
 "LEARN_COUNT": {
 "2": "#F28FAD"
 },
 "LINK": {
 "2": "#F8BD96"
 },
 "MARKED_BG": {
 "2": "#FAE3B0"
 },
 "MEDIUM_BORDER": {
 "2": "#302D41"
 },
 "NEW_COUNT": {
 "2": "#96CDFB"
 },
 "REVIEW_COUNT": {
 "2": "#ABE9B3"
 },
 "SCROLLBAR_BG": [
 "Scrollbar background",
 "#d6d6d6",
 "#363636",
 "--scrollbar-bg"
 ],
 "SCROLLBAR_BG_ACTIVE": [
 "Scrollbar background (active)",
 "#afafaf",
 "#636363",
 "--scrollbar-bg-active"
 ],
 "SCROLLBAR_BG_HOVER": [
 "Scrollbar background (hover)",
 "#c4c4c4",
 "#454545",
 "--scrollbar-bg-hover"
 ],
 "SELECTED_BG": [
 "Selected Bg",
 "#d6d6d680",
 "#93c5fd80",
 "--selected-bg"
 ],
 "SELECTED_FG": [
 "Selected Fg",
 "black",
 "white",
 "--selected-fg"
 ],
 "SHADOW": [
 "Shadow",
 "#c4c4c4",
 "#27987f",
 "--shadow"
 ],
 "SHADOW_FOCUS": [
 "Shadow (focused input)",
 "#6366f1",
 "#6366f1",
 "--shadow-focus"
 ],
 "SHADOW_INSET": [
 "Shadow (inset)",
 "#454545",
 "#202020",
 "--shadow-inset"
 ],
 "SHADOW_SUBTLE": [
 "Shadow (subtle)",
 "#737373",
 "#363636",
 "--shadow-subtle"
 ],
 "SLIGHTLY_GREY_TEXT": {
 "2": "#C3BAC6"
 },
 "STATE_BURIED": [
 "Buried",
 "#f59e0b",
 "#92400e",
 "--state-buried"
 ],
 "STATE_LEARN": [
 "Learn",
 "#D08770",
 "#ff4b4b",
 "--state-learn"
 ],
 "STATE_MARKED": [
 "Marked",
 "#EBCB8B",
 "#595ab8",
 "--state-marked"
 ],
 "STATE_NEW": [
 "New",
 "#5E81AC",
 "#52beff",
 "--state-new"
 ],
 "STATE_REVIEW": [
 "Review",
 "#A3BE8C",
 "#b3ae36",
 "--state-review"
 ],
 "STATE_SUSPENDED": [
 "Suspended",
 "#3B4252",
 "#a57705",
 "--state-suspended"
 ],
 "SUSPENDED_BG": {
 "2": "#E8A2AF"
 },
 "SUSPENDED_FG": {
 "2": "#D9E0EE"
 },
 "TEXT_FG": {
 "2": "#D9E0EE"
 },
 "TOOLTIP_BG": {
 "2": "#1E1E2E"
 },
 "WINDOW_BG": {
 "2": "#1E1E2E"
 },
 "ZERO_COUNT": {
 "2": "#6E6C7E"
 }
 },
 "version": {
 "major": 2,
 "minor": 1
 }
}

BlueGreenMagick commented 1 year ago

Fixed! I seem to have skipped some when updating the themes.

You'll need to restore the add-on config to default.

AnKingMed commented 1 year ago

Seems to work now!

Any idea if we'll be able to make this work with the fastbar? If not that's ok.

BlueGreenMagick commented 1 year ago

2 remaining problems:

  1. Most theme colors except for canvas are not set to QPalette in MacOS. (Because Anki uses native palette in Mac)
  2. QPalette.Button is set to colors.BUTTON_GRADIENT_START, which I removed and the add-on doesn't change.
BlueGreenMagick commented 1 year ago

Fixed!

It should also work with Fastbar if https://github.com/ankipalace/Fastbar-with-nightmode-support/pull/20 is merged

AnKingMed commented 1 year ago

Everything works great! I just uploaded to Ankiweb and updated the images. Thanks for doing this!