mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
feat: future-due colorblind selection
Signed-off-by: David Brenn <davidbrenn@t-online.de>
This commit is contained in:
parent
8c1bbe0632
commit
8b99a550cd
3 changed files with 10 additions and 28 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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<boolean> {
|
||||
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(
|
||||
|
|
Loading…
Reference in a new issue