Changed theme to liquid glass

This commit is contained in:
patben8 committed 2026-09-25 14:57:27 +02:00
1 parent 950352f7ec
commit 2810f24563
52 files changed
+1353 -529

No files matched your search

@@ -43,10 +43,10 @@ class RekordboxAdapter:
# ---- projection maintenance -----------------------------------------
def _rebuild(self) -> None:
counts = self._store.cue_counts()
kinds = self._store.cue_kinds()
self._index.rebuild(
[
projection.to_track(row, counts.get(str(row.ID), (0, 0)))
projection.to_track(row, kinds.get(str(row.ID), ()))
for row in self._store.iter_content()
]
)
@@ -66,9 +66,9 @@ class RekordboxAdapter:
Every mutating command must end in this — a forgotten refresh is a
silently stale projection that no byte- or row-level test would catch.
"""
counts = self._store.cue_counts()
kinds = self._store.cue_kinds()
row = self._store.content(track_id)
self._index.replace(projection.to_track(row, counts.get(str(row.ID), (0, 0))))
self._index.replace(projection.to_track(row, kinds.get(str(row.ID), ())))
def close(self) -> None:
"""Release the database connection.
@@ -7,7 +7,7 @@ from __future__ import annotations
import re
from ...core.model import CuePoint, GridMarker, Track, TrackCues
from ...core.model import CuePoint, GridMarker, HotcueChip, Track, TrackCues
from . import beatgrid
from .cue_types import cue_type, role_and_slot
@@ -97,12 +97,14 @@ def _name_of(related) -> str | None:
return None
def to_track(row, cue_counts: tuple[int, int] = (0, 0)) -> Track:
def to_track(row, cue_kinds=()) -> Track:
"""Project one ``DjmdContent`` row.
`cue_counts` is ``(total, hotcues)`` from the store's single aggregate
`cue_kinds` is this track's ``(Kind, OutMsec)`` pairs from the store's single
query — passed in rather than read off the row, which would be a per-track
round trip.
round trip. "Is this a hot cue, and on which pad?" is `role_and_slot`, the
same definition `to_track_cues` uses, so the table's count and dots agree
with the pads shown in the deck (it also rules out the reserved Kind).
**`grid_marker_count` is an approximation here**: the real count needs the
track's ANLZ file, which is far too slow to read for every track at open
@@ -115,7 +117,14 @@ def to_track(row, cue_counts: tuple[int, int] = (0, 0)) -> Track:
On the reference library the two sets agree exactly: all 22 tracks with no
BPM are precisely the 22 with no grid.
"""
total_cues, hotcues = cue_counts
chips: list[HotcueChip] = []
for kind, out_msec in cue_kinds:
role, slot = role_and_slot(kind)
if role == "hotcue" and slot is not None:
# Rekordbox's colour is a palette index nobody has decoded yet (see
# `_cue_color`), so no colour is claimed and the UI uses the type's.
chips.append(HotcueChip(slot=slot, type=cue_type(out_msec), color=None))
chips.sort(key=lambda chip: chip.slot)
key_name = _name_of(getattr(row, "Key", None))
wheel, mode = parse_key(key_name)
return Track(
@@ -142,8 +151,9 @@ def to_track(row, cue_counts: tuple[int, int] = (0, 0)) -> Track:
last_played=None, # not modelled as a date in master.db
release_date=_iso_date(getattr(row, "ReleaseDate", None)),
filepath=str(getattr(row, "FolderPath", "") or "") or None,
cue_count=total_cues,
hotcue_count=hotcues,
cue_count=len(cue_kinds),
hotcue_count=len(chips),
hotcues=chips,
grid_marker_count=1 if (_bpm(row) and getattr(row, "AnalysisDataPath", None)) else 0,
grid_locked=False, # Rekordbox has no per-track grid lock
media_kind="audio",
+12 -13
View File
@@ -171,23 +171,22 @@ class RekordboxStore:
raise NotFound(f"No track {track_id!r}")
return row
def cue_counts(self) -> dict[str, tuple[int, int]]:
"""``{track_id: (total_cues, hotcue_count)}`` in one aggregate query."""
def cue_kinds(self) -> dict[str, list[tuple[int | None, int | None]]]:
"""``{track_id: [(Kind, OutMsec), ...]}`` for every live cue, in one query.
Just enough per cue for the library table's count and hotcue dots,
without a per-track round trip. What a ``Kind`` means is decided in the
projection, by the same `role_and_slot` the deck's cues use, so the
table and the pads cannot disagree.
"""
t = self._tables
rows = self._db.session.execute(
select(t.DjmdCue.ContentID, t.DjmdCue.Kind, func.count())
select(t.DjmdCue.ContentID, t.DjmdCue.Kind, t.DjmdCue.OutMsec)
.where(t.DjmdCue.rb_local_deleted == 0)
.group_by(t.DjmdCue.ContentID, t.DjmdCue.Kind)
).all()
out: dict[str, tuple[int, int]] = {}
for content_id, kind, n in rows:
total, hot = out.get(str(content_id), (0, 0))
# "Is this a hot cue?" must mean the same here as in the projection,
# or the count in the library table disagrees with the pads shown in
# the deck. `role_and_slot` is the single definition — it also rules
# out the reserved Kind, which occupies no pad.
is_hotcue = role_and_slot(kind)[0] == "hotcue"
out[str(content_id)] = (total + n, hot + (n if is_hotcue else 0))
out: dict[str, list[tuple[int | None, int | None]]] = {}
for content_id, kind, out_msec in rows:
out.setdefault(str(content_id), []).append((kind, out_msec))
return out
def cues(self, track_id: str) -> list: