format: formatted some code

This commit is contained in:
TheFefel 2025-08-14 16:13:40 +02:00
parent bd9854c80e
commit 9f16a92056
12 changed files with 42 additions and 64 deletions

View file

@ -221,7 +221,6 @@ class Preferences(QDialog):
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)
self.update_login_status()
qconnect(self.form.syncLogout.clicked, self.sync_logout)
qconnect(self.form.syncLogin.clicked, self.sync_login)
@ -359,8 +358,6 @@ class Preferences(QDialog):
self.form.theme.setCurrentIndex(self.mw.pm.theme().value)
qconnect(self.form.theme.currentIndexChanged, self.on_theme_changed)
self.form.styleComboBox.addItems(["Anki"] + (["Native"] if not is_win else []))
self.form.styleComboBox.setCurrentIndex(self.mw.pm.get_widget_style())
qconnect(
@ -372,7 +369,9 @@ class Preferences(QDialog):
qconnect(self.form.resetWindowSizes.clicked, self.on_reset_window_sizes)
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_video_driver()
@ -387,7 +386,6 @@ class Preferences(QDialog):
# checkbox is unchecked
self.mw.pm.set_color_blind(False)
def update_global(self) -> None:
restart_required = False

View file

@ -151,7 +151,6 @@ class NewDeckStats(QDialog):
self.form.web.load_sveltekit_page("graphs")
class DeckStats(QDialog):
"""Legacy deck stats, used by some add-ons."""

View file

@ -10,6 +10,7 @@ import type { CountableTimeInterval } from "d3";
import { timeHour } from "d3";
import {
interpolateBlues,
interpolateMagma,
pointer,
scaleLinear,
scaleSequentialSqrt,
@ -20,7 +21,6 @@ import {
timeSaturday,
timeSunday,
timeYear,
interpolateMagma
} from "d3";
import type { GraphBounds, SearchDispatch } from "./graph-helpers";
@ -141,7 +141,6 @@ export function renderCalendar(
const isColorBlindMode = (window as any).colorBlindMode;
let gradient;
if (isColorBlindMode) {

View file

@ -33,8 +33,7 @@ export interface GraphData {
let barColours;
if((window as any).colorBlindMode)
{
if ((window as any).colorBlindMode) {
barColours = [
colorBlindColors.new, /* new */
colorBlindColors.learn, /* learn */
@ -44,9 +43,7 @@ if((window as any).colorBlindMode)
colorBlindColors.suspended, /* suspended */
colorBlindColors.buried, /* buried */
];
}
else
{
} else {
barColours = [
schemeBlues[5][2], /* new */
schemeOranges[5][2], /* learn */

View file

@ -84,15 +84,11 @@ export function prepareData(
.thresholds(ticks)(allEases.entries() as any);
const total = sum(bins as any, getNumericMapBinValue);
let colourScale;
if ((window as any).colorBlindMode)
{
if ((window as any).colorBlindMode) {
colourScale = scaleSequential(interpolateViridis).domain([xMin, 300]);
}
else
{
} else {
colourScale = scaleSequential(interpolateRdYlGn).domain([xMin, 300]);
}

View file

@ -10,7 +10,7 @@ import * as tr from "@generated/ftl";
import { localizedNumber } from "@tslib/i18n";
import { dayLabel } from "@tslib/time";
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 { getNumericMapBinValue, GraphRange, numericMap } from "./graph-helpers";
@ -123,11 +123,8 @@ export function buildHistogram(
adjustedRange = scaleLinear().range([0.7, 0.3]);
}
const total = sum(bins as any, getNumericMapBinValue);
function hoverText(
bin: Bin<number, number>,
cumulative: number,
@ -142,9 +139,6 @@ export function buildHistogram(
return `${days}:<br>${cards}<br>${totalLabel}: ${localizedNumber(cumulative)}`;
}
function onClick(bin: Bin<number, number>): void {
const start = bin.x0!;
// x1 in last bin is inclusive

View file

@ -117,5 +117,5 @@ export const colorBlindColors = {
mature: "#882255",
suspended: "#DDCC77",
buried: "#332288",
filtered: "#AA4499"
filtered: "#AA4499",
};

View file

@ -150,13 +150,10 @@ export function prepareIntervalData(
let adjustedRange;
let colourScale;
if ((window as any).colorBlindMode)
{
if ((window as any).colorBlindMode) {
adjustedRange = scaleLinear().range([0.3, 0.7]);
colourScale = scaleSequential((n) => interpolateViridis(adjustedRange(n)!)).domain([xMax!, xMin!]);
}
else
{
} else {
adjustedRange = scaleLinear().range([0.7, 0.3]);
colourScale = scaleSequential((n) => interpolateBlues(adjustedRange(n)!)).domain([xMax!, xMin!]);
}

View file

@ -16,8 +16,10 @@ import {
axisLeft,
axisRight,
bin,
color,
cumsum,
curveBasis,
hsl,
interpolateBlues,
interpolateGreens,
interpolatePurples,
@ -30,8 +32,6 @@ import {
scaleSequential,
select,
sum,
color,
hsl
} from "d3";
import { colorBlindColors, type GraphBounds, type TableDatum } from "./graph-helpers";
@ -193,10 +193,9 @@ export function renderReviews(
const colorBlindMode = (window as any).colorBlindMode;
function makeColorBlindGradient(baseHex: string, satAdjust = 0.02, lightAdjust = 0.02) {
const base = color(baseHex);
if (!base) {throw new Error(`Invalid color: ${baseHex}`)};
if (!base) { throw new Error(`Invalid color: ${baseHex}`); }
const lighter = hsl(base);
lighter.s = Math.min(1, lighter.s + satAdjust);
@ -216,7 +215,7 @@ export function renderReviews(
young: makeColorBlindGradient(colorBlindColors.young),
suspended: makeColorBlindGradient(colorBlindColors.suspended),
buried: makeColorBlindGradient(colorBlindColors.buried),
filtered: makeColorBlindGradient(colorBlindColors.filtered)
filtered: makeColorBlindGradient(colorBlindColors.filtered),
};
Object.values(colorBlindScales).forEach(scale => scale.domain(x.domain() as any));
@ -236,7 +235,6 @@ export function renderReviews(
}
}
function valueLabel(n: number): string {
if (showTime) {
return timeSpan(n / 1000, false, true, TimespanUnit.Hours);