diff --git a/qt/aqt/preferences.py b/qt/aqt/preferences.py index a9dd53c25..2f12e7f4b 100644 --- a/qt/aqt/preferences.py +++ b/qt/aqt/preferences.py @@ -370,12 +370,9 @@ class Preferences(QDialog): ) self.form.styleLabel.setVisible(not is_win) self.form.styleComboBox.setVisible(not is_win) - qconnect(self.form.resetWindowSizes.clicked, self.on_reset_window_sizes) self.form.color_blind.setChecked(self.mw.pm.color_blind()) - js_code = f"window.colorBlindMode = true;" - self.mw.web.eval(js_code) qconnect(self.form.color_blind.stateChanged, self.on_my_checkbox_changed) diff --git a/qt/aqt/stats.py b/qt/aqt/stats.py index 473d15567..e080c18d4 100644 --- a/qt/aqt/stats.py +++ b/qt/aqt/stats.py @@ -132,17 +132,10 @@ class NewDeckStats(QDialog): pass def _on_bridge_cmd(self, cmd: str) -> bool: - print("Bridge command called:") if cmd.startswith("browserSearch"): _, query = cmd.split(":", 1) browser = aqt.dialogs.open("Browser", self.mw) browser.search_for(query) - if cmd.startswith("getColorBlindSetting"): - print("getColorBlindSetting called") - is_color_blind = self.mw.pm.color_blind() - js_code = f"window.__setColorBlindSetting({str(is_color_blind).lower()});" - self.mw.web.eval(js_code) - return True return False def refresh(self) -> None: diff --git a/ts/routes/graphs/future-due.ts b/ts/routes/graphs/future-due.ts index 5a18cadfd..d38c176d9 100644 --- a/ts/routes/graphs/future-due.ts +++ b/ts/routes/graphs/future-due.ts @@ -4,7 +4,6 @@ /* eslint @typescript-eslint/no-explicit-any: "off", */ -declare function pycmd(command: string): void; import type { GraphsResponse } from "@generated/anki/stats_pb"; import * as tr from "@generated/ftl"; @@ -110,31 +109,24 @@ export function buildHistogram( const xTickFormat = (n: number): string => localizedNumber(n); - const adjustedRange = scaleLinear().range([0.0, 1]); - const colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMin!, xMax!]); + let adjustedRange = scaleLinear().range([0.0, 1]); + const isColorBlindMode = (window as any).colorBlindMode; - getColorBlindSetting().then((setting) => { - console.log("Color Blind Setting:", setting); - }); + let colourScale; + if(isColorBlindMode) { + colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMin!, xMax!]); + adjustedRange = scaleLinear().range([0.0, 1]); + } else { + colourScale = scaleSequential((n) => interpolateGreens(adjustedRange(n)!)).domain([xMin!, xMax!]); + adjustedRange = scaleLinear().range([0.7, 0.3]); + } const total = sum(bins as any, getNumericMapBinValue); - function getColorBlindSetting(): Promise { - return new Promise((resolve) => { - // Define the global callback first - (window as any).__setColorBlindSetting = (val: boolean) => { - delete (window as any).__setColorBlindSetting; // optional cleanup - resolve(val); - }; - - // Then trigger the Python call - pycmd("getColorBlindSetting"); - }); - } function hoverText(