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

@@ -24,7 +24,7 @@ from pathlib import Path
from ...core.adapter import Unsupported
from ...core.capabilities import Capabilities
from ...core.model import PlaylistNode, Track, TrackCues
from ...core.model import HotcueChip, PlaylistNode, Track, TrackCues
from ...core.pathmap import PathMapping, common_dir_prefix
from ...core.query import TrackIndex
from . import capabilities as caps
@@ -125,7 +125,15 @@ class OneLibraryAdapter:
if track is not None:
track.grid_marker_count = len(result.grid_markers)
track.cue_count = len(result.cues)
track.hotcue_count = sum(1 for c in result.cues if c.role == "hotcue")
track.hotcues = sorted(
(
HotcueChip(slot=c.slot, type=c.type, color=c.color)
for c in result.cues
if c.role == "hotcue" and c.slot is not None
),
key=lambda chip: chip.slot,
)
track.hotcue_count = len(track.hotcues)
return result
# ---- playlists -------------------------------------------------------
@@ -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:
@@ -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 NATIVE_TO_CUE_TYPE
@@ -83,8 +83,19 @@ def to_track(e) -> Track:
# question, two answers.
markers = beatgrid.grid_markers(e)
cues = [c for c in (e.cue_v2 or []) if getattr(c, "grid", None) is None]
hotcues = sum(
1 for c in cues if c.hotcue is not None and c.hotcue >= 0
# The same "is this in the bank" test as `to_track_cues`' slot, so the
# table's dots and the deck's pads cannot disagree.
chips = sorted(
(
HotcueChip(
slot=c.hotcue,
type=NATIVE_TO_CUE_TYPE.get(c.type, "cue"),
color=c.color or None,
)
for c in cues
if c.hotcue is not None and c.hotcue >= 0
),
key=lambda chip: chip.slot,
)
wheel, mode = parse_key(info.key if info else None)
return Track(
@@ -111,7 +122,8 @@ def to_track(e) -> Track:
release_date=iso_date(info.release_date if info else None),
filepath=_display_path(loc) if loc else None,
cue_count=len(cues),
hotcue_count=hotcues,
hotcue_count=len(chips),
hotcues=chips,
grid_marker_count=len(markers),
grid_locked=bool(e.lock),
media_kind="stem" if getattr(e, "stems", None) is not None else "audio",
+16
View File
@@ -16,6 +16,18 @@ from pydantic import BaseModel, ConfigDict, Field
from .capabilities import CueRole, CueType, MediaKind, PlaylistKind
class HotcueChip(BaseModel):
"""One occupied hotcue slot, as the library table previews it.
Deliberately far smaller than a `CuePoint`: it rides on every `Track` in the
whole-library fetch, and a row only needs enough to draw a coloured dot.
"""
slot: int
type: CueType = "cue"
color: str | None = None # "#RRGGBB" as the platform stored it
class Track(BaseModel):
"""A single track in the library, as the app sees it."""
@@ -47,6 +59,10 @@ class Track(BaseModel):
filepath: str | None = None # human-readable OS path
cue_count: int = 0
hotcue_count: int = 0
# The occupied hotcue slots, ordered by slot. Where cues are parsed lazily
# (OneLibrary) this is empty until `track_cues()` corrects it, exactly like
# `hotcue_count` — the two must always agree.
hotcues: list[HotcueChip] = Field(default_factory=list)
# 0 = no beatgrid, 1 = constant tempo, >1 = a flexible (multi-tempo) grid.
grid_marker_count: int = 0
grid_locked: bool = False
+1
View File
@@ -314,6 +314,7 @@ from .core.model import ( # noqa: E402,F401
Facets,
GenreCount,
GridMarker,
HotcueChip,
PlaylistNode,
PrefixGroup,
PrefixSuggestions,