mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
chore: get preferences into ts files
This commit is contained in:
parent
cdeaf3875a
commit
77649c4a89
3 changed files with 36 additions and 1 deletions
|
@ -370,9 +370,12 @@ 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,11 +132,17 @@ 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,6 +4,7 @@
|
||||||
/* 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";
|
||||||
|
@ -112,8 +113,30 @@ export function buildHistogram(
|
||||||
const adjustedRange = scaleLinear().range([0.0, 1]);
|
const adjustedRange = scaleLinear().range([0.0, 1]);
|
||||||
const colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMin!, xMax!]);
|
const colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMin!, xMax!]);
|
||||||
|
|
||||||
|
|
||||||
|
getColorBlindSetting().then((setting) => {
|
||||||
|
console.log("Color Blind Setting:", setting);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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(
|
||||||
bin: Bin<number, number>,
|
bin: Bin<number, number>,
|
||||||
cumulative: number,
|
cumulative: number,
|
||||||
|
@ -128,6 +151,9 @@ export function buildHistogram(
|
||||||
return `${days}:<br>${cards}<br>${totalLabel}: ${localizedNumber(cumulative)}`;
|
return `${days}:<br>${cards}<br>${totalLabel}: ${localizedNumber(cumulative)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function onClick(bin: Bin<number, number>): void {
|
function onClick(bin: Bin<number, number>): void {
|
||||||
const start = bin.x0!;
|
const start = bin.x0!;
|
||||||
// x1 in last bin is inclusive
|
// x1 in last bin is inclusive
|
||||||
|
|
Loading…
Reference in a new issue