mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
format: formatted some code
This commit is contained in:
parent
bd9854c80e
commit
9f16a92056
12 changed files with 42 additions and 64 deletions
|
@ -221,7 +221,6 @@ class Preferences(QDialog):
|
||||||
self.form.check_for_updates.setChecked(self.mw.pm.check_for_updates())
|
self.form.check_for_updates.setChecked(self.mw.pm.check_for_updates())
|
||||||
qconnect(self.form.check_for_updates.stateChanged, self.mw.pm.set_update_check)
|
qconnect(self.form.check_for_updates.stateChanged, self.mw.pm.set_update_check)
|
||||||
|
|
||||||
|
|
||||||
self.update_login_status()
|
self.update_login_status()
|
||||||
qconnect(self.form.syncLogout.clicked, self.sync_logout)
|
qconnect(self.form.syncLogout.clicked, self.sync_logout)
|
||||||
qconnect(self.form.syncLogin.clicked, self.sync_login)
|
qconnect(self.form.syncLogin.clicked, self.sync_login)
|
||||||
|
@ -359,8 +358,6 @@ class Preferences(QDialog):
|
||||||
self.form.theme.setCurrentIndex(self.mw.pm.theme().value)
|
self.form.theme.setCurrentIndex(self.mw.pm.theme().value)
|
||||||
qconnect(self.form.theme.currentIndexChanged, self.on_theme_changed)
|
qconnect(self.form.theme.currentIndexChanged, self.on_theme_changed)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.form.styleComboBox.addItems(["Anki"] + (["Native"] if not is_win else []))
|
self.form.styleComboBox.addItems(["Anki"] + (["Native"] if not is_win else []))
|
||||||
self.form.styleComboBox.setCurrentIndex(self.mw.pm.get_widget_style())
|
self.form.styleComboBox.setCurrentIndex(self.mw.pm.get_widget_style())
|
||||||
qconnect(
|
qconnect(
|
||||||
|
@ -372,7 +369,9 @@ class Preferences(QDialog):
|
||||||
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())
|
||||||
qconnect(self.form.color_blind.stateChanged, self.on_color_blind_checkbox_changed)
|
qconnect(
|
||||||
|
self.form.color_blind.stateChanged, self.on_color_blind_checkbox_changed
|
||||||
|
)
|
||||||
|
|
||||||
self.setup_language()
|
self.setup_language()
|
||||||
self.setup_video_driver()
|
self.setup_video_driver()
|
||||||
|
@ -387,7 +386,6 @@ class Preferences(QDialog):
|
||||||
# checkbox is unchecked
|
# checkbox is unchecked
|
||||||
self.mw.pm.set_color_blind(False)
|
self.mw.pm.set_color_blind(False)
|
||||||
|
|
||||||
|
|
||||||
def update_global(self) -> None:
|
def update_global(self) -> None:
|
||||||
restart_required = False
|
restart_required = False
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,6 @@ class NewDeckStats(QDialog):
|
||||||
self.form.web.load_sveltekit_page("graphs")
|
self.form.web.load_sveltekit_page("graphs")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DeckStats(QDialog):
|
class DeckStats(QDialog):
|
||||||
"""Legacy deck stats, used by some add-ons."""
|
"""Legacy deck stats, used by some add-ons."""
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ export function buildHistogram(
|
||||||
const isColourBlindMode = (window as any).colorBlindMode;
|
const isColourBlindMode = (window as any).colorBlindMode;
|
||||||
|
|
||||||
// Changing color based on mode
|
// Changing color based on mode
|
||||||
if(isColourBlindMode){
|
if (isColourBlindMode) {
|
||||||
adjustedRange = scaleLinear().range([0.3, 0.7]);
|
adjustedRange = scaleLinear().range([0.3, 0.7]);
|
||||||
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMax!, xMin!]);
|
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMax!, xMin!]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {
|
||||||
sum,
|
sum,
|
||||||
} from "d3";
|
} from "d3";
|
||||||
|
|
||||||
import {type GraphBounds } from "./graph-helpers";
|
import { type GraphBounds } from "./graph-helpers";
|
||||||
import { GraphRange } from "./graph-helpers";
|
import { GraphRange } from "./graph-helpers";
|
||||||
import { setDataAvailable } from "./graph-helpers";
|
import { setDataAvailable } from "./graph-helpers";
|
||||||
import { hideTooltip, showTooltip } from "./tooltip-utils.svelte";
|
import { hideTooltip, showTooltip } from "./tooltip-utils.svelte";
|
||||||
|
@ -167,7 +167,7 @@ export function renderButtons(
|
||||||
let colour;
|
let colour;
|
||||||
|
|
||||||
// Changing color based on mode
|
// Changing color based on mode
|
||||||
if(isColourBlindMode){
|
if (isColourBlindMode) {
|
||||||
colour = scaleSequential(interpolateViridis).domain([1, 4]);
|
colour = scaleSequential(interpolateViridis).domain([1, 4]);
|
||||||
} else {
|
} else {
|
||||||
colour = scaleSequential(interpolateRdYlGn).domain([1, 4]);
|
colour = scaleSequential(interpolateRdYlGn).domain([1, 4]);
|
||||||
|
|
|
@ -10,6 +10,7 @@ import type { CountableTimeInterval } from "d3";
|
||||||
import { timeHour } from "d3";
|
import { timeHour } from "d3";
|
||||||
import {
|
import {
|
||||||
interpolateBlues,
|
interpolateBlues,
|
||||||
|
interpolateMagma,
|
||||||
pointer,
|
pointer,
|
||||||
scaleLinear,
|
scaleLinear,
|
||||||
scaleSequentialSqrt,
|
scaleSequentialSqrt,
|
||||||
|
@ -20,7 +21,6 @@ import {
|
||||||
timeSaturday,
|
timeSaturday,
|
||||||
timeSunday,
|
timeSunday,
|
||||||
timeYear,
|
timeYear,
|
||||||
interpolateMagma
|
|
||||||
} from "d3";
|
} from "d3";
|
||||||
|
|
||||||
import type { GraphBounds, SearchDispatch } from "./graph-helpers";
|
import type { GraphBounds, SearchDispatch } from "./graph-helpers";
|
||||||
|
@ -137,11 +137,10 @@ export function renderCalendar(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const data = Array.from(dayMap.values());
|
const data = Array.from(dayMap.values());
|
||||||
const cappedRange = scaleLinear().range([1,0]);
|
const cappedRange = scaleLinear().range([1, 0]);
|
||||||
|
|
||||||
const isColorBlindMode = (window as any).colorBlindMode;
|
const isColorBlindMode = (window as any).colorBlindMode;
|
||||||
|
|
||||||
|
|
||||||
let gradient;
|
let gradient;
|
||||||
|
|
||||||
if (isColorBlindMode) {
|
if (isColorBlindMode) {
|
||||||
|
|
|
@ -33,8 +33,7 @@ export interface GraphData {
|
||||||
|
|
||||||
let barColours;
|
let barColours;
|
||||||
|
|
||||||
if((window as any).colorBlindMode)
|
if ((window as any).colorBlindMode) {
|
||||||
{
|
|
||||||
barColours = [
|
barColours = [
|
||||||
colorBlindColors.new, /* new */
|
colorBlindColors.new, /* new */
|
||||||
colorBlindColors.learn, /* learn */
|
colorBlindColors.learn, /* learn */
|
||||||
|
@ -44,9 +43,7 @@ if((window as any).colorBlindMode)
|
||||||
colorBlindColors.suspended, /* suspended */
|
colorBlindColors.suspended, /* suspended */
|
||||||
colorBlindColors.buried, /* buried */
|
colorBlindColors.buried, /* buried */
|
||||||
];
|
];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
barColours = [
|
barColours = [
|
||||||
schemeBlues[5][2], /* new */
|
schemeBlues[5][2], /* new */
|
||||||
schemeOranges[5][2], /* learn */
|
schemeOranges[5][2], /* learn */
|
||||||
|
|
|
@ -84,15 +84,11 @@ export function prepareData(
|
||||||
.thresholds(ticks)(allEases.entries() as any);
|
.thresholds(ticks)(allEases.entries() as any);
|
||||||
const total = sum(bins as any, getNumericMapBinValue);
|
const total = sum(bins as any, getNumericMapBinValue);
|
||||||
|
|
||||||
|
|
||||||
let colourScale;
|
let colourScale;
|
||||||
|
|
||||||
if ((window as any).colorBlindMode)
|
if ((window as any).colorBlindMode) {
|
||||||
{
|
|
||||||
colourScale = scaleSequential(interpolateViridis).domain([xMin, 300]);
|
colourScale = scaleSequential(interpolateViridis).domain([xMin, 300]);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
colourScale = scaleSequential(interpolateRdYlGn).domain([xMin, 300]);
|
colourScale = scaleSequential(interpolateRdYlGn).domain([xMin, 300]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import * as tr from "@generated/ftl";
|
||||||
import { localizedNumber } from "@tslib/i18n";
|
import { localizedNumber } from "@tslib/i18n";
|
||||||
import { dayLabel } from "@tslib/time";
|
import { dayLabel } from "@tslib/time";
|
||||||
import type { Bin } from "d3";
|
import type { Bin } from "d3";
|
||||||
import { bin, extent, interpolateGreens, scaleLinear, scaleSequential, sum, interpolateViridis} from "d3";
|
import { bin, extent, interpolateGreens, interpolateViridis, scaleLinear, scaleSequential, sum } from "d3";
|
||||||
|
|
||||||
import type { SearchDispatch, TableDatum } from "./graph-helpers";
|
import type { SearchDispatch, TableDatum } from "./graph-helpers";
|
||||||
import { getNumericMapBinValue, GraphRange, numericMap } from "./graph-helpers";
|
import { getNumericMapBinValue, GraphRange, numericMap } from "./graph-helpers";
|
||||||
|
@ -115,7 +115,7 @@ export function buildHistogram(
|
||||||
|
|
||||||
let colourScale;
|
let colourScale;
|
||||||
|
|
||||||
if(isColorBlindMode) {
|
if (isColorBlindMode) {
|
||||||
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMin!, xMax!]);
|
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMin!, xMax!]);
|
||||||
adjustedRange = scaleLinear().range([0.0, 1]);
|
adjustedRange = scaleLinear().range([0.0, 1]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -123,11 +123,8 @@ export function buildHistogram(
|
||||||
adjustedRange = scaleLinear().range([0.7, 0.3]);
|
adjustedRange = scaleLinear().range([0.7, 0.3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const total = sum(bins as any, getNumericMapBinValue);
|
const total = sum(bins as any, getNumericMapBinValue);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function hoverText(
|
function hoverText(
|
||||||
bin: Bin<number, number>,
|
bin: Bin<number, number>,
|
||||||
cumulative: number,
|
cumulative: number,
|
||||||
|
@ -142,9 +139,6 @@ 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
|
||||||
|
|
|
@ -117,5 +117,5 @@ export const colorBlindColors = {
|
||||||
mature: "#882255",
|
mature: "#882255",
|
||||||
suspended: "#DDCC77",
|
suspended: "#DDCC77",
|
||||||
buried: "#332288",
|
buried: "#332288",
|
||||||
filtered: "#AA4499"
|
filtered: "#AA4499",
|
||||||
};
|
};
|
||||||
|
|
|
@ -88,7 +88,7 @@ export function renderHours(
|
||||||
let colour;
|
let colour;
|
||||||
const isColorBlindMode = (window as any).colorBlindMode;
|
const isColorBlindMode = (window as any).colorBlindMode;
|
||||||
|
|
||||||
if(isColorBlindMode) {
|
if (isColorBlindMode) {
|
||||||
cappedRange = scaleLinear().range([0.0, 1]);
|
cappedRange = scaleLinear().range([0.0, 1]);
|
||||||
colour = scaleSequential((n) => interpolateViridis(cappedRange(n)!)).domain([
|
colour = scaleSequential((n) => interpolateViridis(cappedRange(n)!)).domain([
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -150,13 +150,10 @@ export function prepareIntervalData(
|
||||||
let adjustedRange;
|
let adjustedRange;
|
||||||
let colourScale;
|
let colourScale;
|
||||||
|
|
||||||
if ((window as any).colorBlindMode)
|
if ((window as any).colorBlindMode) {
|
||||||
{
|
|
||||||
adjustedRange = scaleLinear().range([0.3, 0.7]);
|
adjustedRange = scaleLinear().range([0.3, 0.7]);
|
||||||
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMax!, xMin!]);
|
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMax!, xMin!]);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
adjustedRange = scaleLinear().range([0.7, 0.3]);
|
adjustedRange = scaleLinear().range([0.7, 0.3]);
|
||||||
colourScale = scaleSequential((n) => interpolateBlues(adjustedRange(n)!)).domain([xMax!, xMin!]);
|
colourScale = scaleSequential((n) => interpolateBlues(adjustedRange(n)!)).domain([xMax!, xMin!]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,10 @@ import {
|
||||||
axisLeft,
|
axisLeft,
|
||||||
axisRight,
|
axisRight,
|
||||||
bin,
|
bin,
|
||||||
|
color,
|
||||||
cumsum,
|
cumsum,
|
||||||
curveBasis,
|
curveBasis,
|
||||||
|
hsl,
|
||||||
interpolateBlues,
|
interpolateBlues,
|
||||||
interpolateGreens,
|
interpolateGreens,
|
||||||
interpolatePurples,
|
interpolatePurples,
|
||||||
|
@ -30,8 +32,6 @@ import {
|
||||||
scaleSequential,
|
scaleSequential,
|
||||||
select,
|
select,
|
||||||
sum,
|
sum,
|
||||||
color,
|
|
||||||
hsl
|
|
||||||
} from "d3";
|
} from "d3";
|
||||||
|
|
||||||
import { colorBlindColors, type GraphBounds, type TableDatum } from "./graph-helpers";
|
import { colorBlindColors, type GraphBounds, type TableDatum } from "./graph-helpers";
|
||||||
|
@ -193,10 +193,9 @@ export function renderReviews(
|
||||||
|
|
||||||
const colorBlindMode = (window as any).colorBlindMode;
|
const colorBlindMode = (window as any).colorBlindMode;
|
||||||
|
|
||||||
|
|
||||||
function makeColorBlindGradient(baseHex: string, satAdjust = 0.02, lightAdjust = 0.02) {
|
function makeColorBlindGradient(baseHex: string, satAdjust = 0.02, lightAdjust = 0.02) {
|
||||||
const base = color(baseHex);
|
const base = color(baseHex);
|
||||||
if (!base) {throw new Error(`Invalid color: ${baseHex}`)};
|
if (!base) { throw new Error(`Invalid color: ${baseHex}`); }
|
||||||
|
|
||||||
const lighter = hsl(base);
|
const lighter = hsl(base);
|
||||||
lighter.s = Math.min(1, lighter.s + satAdjust);
|
lighter.s = Math.min(1, lighter.s + satAdjust);
|
||||||
|
@ -216,7 +215,7 @@ export function renderReviews(
|
||||||
young: makeColorBlindGradient(colorBlindColors.young),
|
young: makeColorBlindGradient(colorBlindColors.young),
|
||||||
suspended: makeColorBlindGradient(colorBlindColors.suspended),
|
suspended: makeColorBlindGradient(colorBlindColors.suspended),
|
||||||
buried: makeColorBlindGradient(colorBlindColors.buried),
|
buried: makeColorBlindGradient(colorBlindColors.buried),
|
||||||
filtered: makeColorBlindGradient(colorBlindColors.filtered)
|
filtered: makeColorBlindGradient(colorBlindColors.filtered),
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.values(colorBlindScales).forEach(scale => scale.domain(x.domain() as any));
|
Object.values(colorBlindScales).forEach(scale => scale.domain(x.domain() as any));
|
||||||
|
@ -236,7 +235,6 @@ export function renderReviews(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function valueLabel(n: number): string {
|
function valueLabel(n: number): string {
|
||||||
if (showTime) {
|
if (showTime) {
|
||||||
return timeSpan(n / 1000, false, true, TimespanUnit.Hours);
|
return timeSpan(n / 1000, false, true, TimespanUnit.Hours);
|
||||||
|
|
Loading…
Reference in a new issue