mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12: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.styleLabel.setVisible(not is_win)
|
||||||
self.form.styleComboBox.setVisible(not is_win)
|
self.form.styleComboBox.setVisible(not is_win)
|
||||||
|
|
||||||
qconnect(self.form.resetWindowSizes.clicked, self.on_reset_window_sizes)
|
qconnect(self.form.resetWindowSizes.clicked, self.on_reset_window_sizes)
|
||||||
|
|
||||||
self.form.color_blind.setChecked(self.mw.pm.color_blind())
|
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)
|
qconnect(self.form.color_blind.stateChanged, self.on_my_checkbox_changed)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -132,17 +132,10 @@ class NewDeckStats(QDialog):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _on_bridge_cmd(self, cmd: str) -> bool:
|
def _on_bridge_cmd(self, cmd: str) -> bool:
|
||||||
print("Bridge command called:")
|
|
||||||
if cmd.startswith("browserSearch"):
|
if cmd.startswith("browserSearch"):
|
||||||
_, query = cmd.split(":", 1)
|
_, query = cmd.split(":", 1)
|
||||||
browser = aqt.dialogs.open("Browser", self.mw)
|
browser = aqt.dialogs.open("Browser", self.mw)
|
||||||
browser.search_for(query)
|
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
|
return False
|
||||||
|
|
||||||
def refresh(self) -> None:
|
def refresh(self) -> None:
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
/* eslint
|
/* eslint
|
||||||
@typescript-eslint/no-explicit-any: "off",
|
@typescript-eslint/no-explicit-any: "off",
|
||||||
*/
|
*/
|
||||||
declare function pycmd(command: string): void;
|
|
||||||
|
|
||||||
import type { GraphsResponse } from "@generated/anki/stats_pb";
|
import type { GraphsResponse } from "@generated/anki/stats_pb";
|
||||||
import * as tr from "@generated/ftl";
|
import * as tr from "@generated/ftl";
|
||||||
|
@ -110,31 +109,24 @@ export function buildHistogram(
|
||||||
|
|
||||||
const xTickFormat = (n: number): string => localizedNumber(n);
|
const xTickFormat = (n: number): string => localizedNumber(n);
|
||||||
|
|
||||||
const adjustedRange = scaleLinear().range([0.0, 1]);
|
let adjustedRange = scaleLinear().range([0.0, 1]);
|
||||||
const colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMin!, xMax!]);
|
|
||||||
|
|
||||||
|
const isColorBlindMode = (window as any).colorBlindMode;
|
||||||
|
|
||||||
getColorBlindSetting().then((setting) => {
|
let colourScale;
|
||||||
console.log("Color Blind Setting:", setting);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
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);
|
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(
|
function hoverText(
|
||||||
|
|
Loading…
Reference in a new issue