- TrackRow: Korean/CJK titles render via layout-assigned width+height (SongCard parity, never femtovg-measured); explicit "E" badge hugs the title text; duration + position number dropped to 13px so they read smaller than the 14px title. - AlbumView: label/awards rail 214->160px with smaller card/icon/padding and centered headings in the compact rail; removed the dark right gutter (full-width Flickable, content clears the scrollbar via the 32px page padding); column headers homologated to Playlist casing (Title/Duration/ Quality), same in LocalAlbumView. - ArtistView: network sidebar auto-collapses on ShellState.content- constrained (the AlbumView signal) and no longer re-opens on artist-> artist navigation (reset_network_sidebar respects the constraint). - Hero titles homologated to Typography.section (18px) across MyQBZ detail, Musician, Label releases, Artists-by-location, Offline Manager. - Lyrics: Qobuz || LRCLIB parallel fetch, next-track prefetch, source footer, asymmetric line fade. cc
574 lines
25 KiB
Plaintext
574 lines
25 KiB
Plaintext
// Offline Cache Manager — the standalone manage-downloads surface (Tauri's
|
|
// OfflineCacheManagerView). Header (Back + title) + a stats bar (totals /
|
|
// usage bar / edit-limit / open-folder / clear-all) + a toolbar (sort
|
|
// dropdown / show-only-failed) over a two-pane body: a left A-Z artist rail
|
|
// and a right scrolling list of album-header (with cover) + track rows
|
|
// (per-row remove / re-download).
|
|
//
|
|
// Rows + artists are precomputed in Rust (crate::offline_manager) and pushed
|
|
// as models; actions go through OfflineManagerActions.
|
|
|
|
import { ScrollView } from "std-widgets.slint";
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { OfflineManagerState, OfflineManagerActions, OfflineRow, OfflineArtist } from "../state.slint";
|
|
import { NavState, TooltipState } from "../state.slint";
|
|
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
|
import { QbzSelect } from "../primitives/QbzSelect.slint";
|
|
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
|
|
import { NavButtons } from "../shell/NavButtons.slint";
|
|
|
|
// A small ghost icon button.
|
|
component IconBtn inherits Rectangle {
|
|
in property <image> icon;
|
|
in property <color> tint: Theme.text-muted;
|
|
callback clicked;
|
|
width: 30px;
|
|
height: 30px;
|
|
border-radius: Radius.sm;
|
|
background: ta.has-hover ? Theme.surface-elevated : transparent;
|
|
QbzIcon {
|
|
source: root.icon;
|
|
width: 16px;
|
|
height: 16px;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
tint: ta.has-hover ? Theme.text-primary : root.tint;
|
|
}
|
|
ta := TouchArea {
|
|
mouse-cursor: pointer;
|
|
clicked => {
|
|
root.clicked();
|
|
}
|
|
}
|
|
}
|
|
|
|
// The cache-status glyph (downloading spins).
|
|
component StatusIcon inherits Rectangle {
|
|
in property <int> status;
|
|
width: 18px;
|
|
height: 18px;
|
|
if root.status == 2: Image {
|
|
width: 16px;
|
|
height: 16px;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
source: @image-url("../assets/icons/loader-circle.svg");
|
|
colorize: Theme.accent;
|
|
transform-rotation: ((animation-tick() / 1ms) * 0.36) * 1deg;
|
|
}
|
|
if root.status != 2: QbzIcon {
|
|
width: 16px;
|
|
height: 16px;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
source: root.status == 3
|
|
? @image-url("../assets/icons/circle-check-big.svg")
|
|
: (root.status == 4
|
|
? @image-url("../assets/icons/triangle-alert.svg")
|
|
: @image-url("../assets/icons/cloud-download.svg"));
|
|
tint: root.status == 3 ? Theme.accent : (root.status == 4 ? #e0564f : Theme.text-muted);
|
|
}
|
|
}
|
|
|
|
// One artist-rail row.
|
|
component ArtistRailRow inherits Rectangle {
|
|
in property <string> name;
|
|
in property <string> meta;
|
|
in property <bool> active;
|
|
callback clicked;
|
|
height: 48px;
|
|
border-radius: 8px;
|
|
background: root.active ? Theme.surface-elevated : (ta.has-hover ? #ffffff10 : transparent);
|
|
HorizontalLayout {
|
|
padding-left: 12px;
|
|
padding-right: 8px;
|
|
VerticalLayout {
|
|
alignment: center;
|
|
spacing: 2px;
|
|
Text {
|
|
text: root.name;
|
|
color: root.active ? Theme.accent : Theme.text-primary;
|
|
font-size: Typography.legal;
|
|
font-weight: root.active ? Typography.semibold : Typography.regular;
|
|
overflow: elide;
|
|
}
|
|
Text {
|
|
text: root.meta;
|
|
color: Theme.text-muted;
|
|
font-size: 11px;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
}
|
|
ta := TouchArea {
|
|
mouse-cursor: pointer;
|
|
clicked => {
|
|
root.clicked();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Bulk-action icon button — homologated with MultiSelectBar's BulkButton
|
|
// (icon + hover tooltip, borderless normal, red-bordered danger) so the
|
|
// offline-cache track rows share the app-wide bulk-bar style. Named
|
|
// distinctly from the existing `IconBtn` (a tinted toolbar glyph button).
|
|
component BulkIconBtn inherits Rectangle {
|
|
in property <image> icon;
|
|
in property <string> tooltip;
|
|
in property <bool> danger: false;
|
|
callback clicked;
|
|
width: 34px;
|
|
height: 30px;
|
|
border-radius: Radius.sm;
|
|
background: root.danger
|
|
? (ta.has-hover ? #ef444433 : transparent)
|
|
: (ta.has-hover ? Theme.surface-hover : transparent);
|
|
border-width: root.danger ? 1px : 0px;
|
|
border-color: #ef4444;
|
|
QbzIcon {
|
|
source: root.icon;
|
|
width: 16px;
|
|
height: 16px;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
tint: root.danger
|
|
? #ef4444
|
|
: (ta.has-hover ? Theme.text-primary : Theme.text-secondary);
|
|
}
|
|
ta := TouchArea {
|
|
mouse-cursor: pointer;
|
|
clicked => {
|
|
root.clicked();
|
|
}
|
|
changed has-hover => {
|
|
if (self.has-hover && root.tooltip != "") {
|
|
TooltipState.text = root.tooltip;
|
|
TooltipState.anchor-x = root.absolute-position.x + root.width / 2;
|
|
TooltipState.anchor-y = root.absolute-position.y;
|
|
TooltipState.show = true;
|
|
} else if (!self.has-hover) {
|
|
TooltipState.show = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export component OfflineManagerView inherits Rectangle {
|
|
background: Theme.surface-main;
|
|
|
|
VerticalLayout {
|
|
padding: 24px;
|
|
spacing: 14px;
|
|
|
|
// Header.
|
|
HorizontalLayout {
|
|
vertical-stretch: 0;
|
|
spacing: 12px;
|
|
NavButtons { }
|
|
VerticalLayout {
|
|
alignment: center;
|
|
Text {
|
|
text: "Offline Cache";
|
|
color: Theme.text-primary;
|
|
// Hero homologated to the canonical 18px (section).
|
|
font-size: Typography.section;
|
|
font-weight: Typography.bold;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Stats bar.
|
|
Rectangle {
|
|
vertical-stretch: 0;
|
|
height: 76px;
|
|
border-radius: Radius.md;
|
|
background: Theme.surface-elevated;
|
|
HorizontalLayout {
|
|
padding: 16px;
|
|
spacing: 20px;
|
|
VerticalLayout {
|
|
alignment: center;
|
|
Text {
|
|
text: OfflineManagerState.tracks-count + " tracks";
|
|
color: Theme.text-primary;
|
|
font-size: Typography.body;
|
|
font-weight: Typography.semibold;
|
|
}
|
|
Text {
|
|
text: OfflineManagerState.size-text + " " + OfflineManagerState.limit-text;
|
|
color: Theme.text-muted;
|
|
font-size: Typography.legal;
|
|
}
|
|
}
|
|
Rectangle {
|
|
horizontal-stretch: 1;
|
|
VerticalLayout {
|
|
alignment: center;
|
|
Rectangle {
|
|
height: 8px;
|
|
border-radius: 4px;
|
|
background: Theme.surface-main;
|
|
Rectangle {
|
|
x: 0;
|
|
y: 0;
|
|
height: parent.height;
|
|
border-radius: 4px;
|
|
width: parent.width * Math.clamp(OfflineManagerState.usage, 0.0, 1.0);
|
|
background: OfflineManagerState.usage >= 1.0 ? #e0564f : Theme.accent;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
HorizontalLayout {
|
|
spacing: 6px;
|
|
Rectangle {
|
|
width: 58px;
|
|
height: 30px;
|
|
border-radius: 6px;
|
|
background: Theme.surface-main;
|
|
border-width: 1px;
|
|
border-color: limit-in.has-focus ? Theme.accent : Theme.border-subtle;
|
|
limit-in := TextInput {
|
|
x: 8px;
|
|
width: parent.width - 16px;
|
|
height: 100%;
|
|
vertical-alignment: center;
|
|
color: Theme.text-primary;
|
|
font-size: Typography.body;
|
|
input-type: number;
|
|
text: OfflineManagerState.limit-gb;
|
|
accepted => {
|
|
OfflineManagerActions.set-limit(self.text.to-float());
|
|
}
|
|
}
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
Text {
|
|
text: "GB";
|
|
color: Theme.text-muted;
|
|
font-size: Typography.legal;
|
|
}
|
|
}
|
|
IconBtn {
|
|
icon: @image-url("../assets/icons/check.svg");
|
|
clicked => {
|
|
OfflineManagerActions.set-limit(limit-in.text.to-float());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconBtn {
|
|
icon: @image-url("../assets/icons/folder.svg");
|
|
clicked => {
|
|
OfflineManagerActions.open-folder();
|
|
}
|
|
}
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconBtn {
|
|
icon: @image-url("../assets/icons/trash-2.svg");
|
|
tint: #e0564f;
|
|
clicked => {
|
|
OfflineManagerActions.clear-all();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Toolbar — sort + show-only-failed.
|
|
HorizontalLayout {
|
|
vertical-stretch: 0;
|
|
spacing: 12px;
|
|
QbzSelect {
|
|
menu-width: 160px;
|
|
sm: true;
|
|
options: [@tr("Sort: A-Z"), @tr("Sort: Recent"), @tr("Sort: Largest"), @tr("Sort: Smallest")];
|
|
current-index: OfflineManagerState.sort-index;
|
|
selected(i) => {
|
|
OfflineManagerActions.set-sort(i);
|
|
}
|
|
}
|
|
Rectangle {
|
|
width: failed-label.preferred-width + 28px;
|
|
height: 32px;
|
|
border-radius: Radius.sm;
|
|
border-width: 1px;
|
|
border-color: OfflineManagerState.show-only-failed ? Theme.accent : Theme.border-subtle;
|
|
background: OfflineManagerState.show-only-failed ? #e0564f22 : (failed-ta.has-hover ? Theme.surface-elevated : transparent);
|
|
failed-label := Text {
|
|
x: 14px;
|
|
text: @tr("Failed only");
|
|
color: OfflineManagerState.show-only-failed ? #e0564f : Theme.text-secondary;
|
|
font-size: Typography.legal;
|
|
vertical-alignment: center;
|
|
height: 100%;
|
|
}
|
|
failed-ta := TouchArea {
|
|
mouse-cursor: pointer;
|
|
clicked => {
|
|
OfflineManagerActions.toggle-failed();
|
|
}
|
|
}
|
|
}
|
|
Rectangle {
|
|
horizontal-stretch: 1;
|
|
} // spacer
|
|
// Bulk actions on the checked tracks.
|
|
if OfflineManagerState.selected-count > 0: HorizontalLayout {
|
|
spacing: 8px;
|
|
VerticalLayout {
|
|
alignment: center;
|
|
Text {
|
|
text: OfflineManagerState.selected-count + @tr(" selected");
|
|
color: Theme.text-muted;
|
|
font-size: Typography.legal;
|
|
}
|
|
}
|
|
BulkIconBtn {
|
|
icon: @image-url("../assets/icons/refresh-cw.svg");
|
|
tooltip: @tr("Re-download");
|
|
clicked => {
|
|
OfflineManagerActions.bulk-redownload();
|
|
}
|
|
}
|
|
BulkIconBtn {
|
|
icon: @image-url("../assets/icons/trash-2.svg");
|
|
tooltip: @tr("Remove");
|
|
danger: true;
|
|
clicked => {
|
|
OfflineManagerActions.bulk-remove();
|
|
}
|
|
}
|
|
}
|
|
// Select all / clear toggle.
|
|
BulkIconBtn {
|
|
icon: OfflineManagerState.selected-count > 0
|
|
? @image-url("../assets/icons/x.svg")
|
|
: @image-url("../assets/icons/square-check-big.svg");
|
|
tooltip: OfflineManagerState.selected-count > 0 ? @tr("Clear") : @tr("Select all");
|
|
clicked => {
|
|
if (OfflineManagerState.selected-count > 0) {
|
|
OfflineManagerActions.clear-selection();
|
|
} else {
|
|
OfflineManagerActions.select-all();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Body — artist rail + rows.
|
|
HorizontalLayout {
|
|
vertical-stretch: 1;
|
|
spacing: 14px;
|
|
|
|
// Left A-Z artist rail.
|
|
Rectangle {
|
|
width: 210px;
|
|
border-radius: Radius.md;
|
|
background: Theme.surface-card;
|
|
ScrollView {
|
|
VerticalLayout {
|
|
padding: 6px;
|
|
spacing: 2px;
|
|
ArtistRailRow {
|
|
name: @tr("All artists");
|
|
meta: OfflineManagerState.tracks-count + " tracks";
|
|
active: OfflineManagerState.selected-artist == "";
|
|
clicked => {
|
|
OfflineManagerActions.select-artist("");
|
|
}
|
|
}
|
|
for a in OfflineManagerState.artists: ArtistRailRow {
|
|
name: a.name;
|
|
meta: a.meta;
|
|
active: a.selected;
|
|
clicked => {
|
|
OfflineManagerActions.select-artist(a.name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Right list.
|
|
Rectangle {
|
|
horizontal-stretch: 1;
|
|
if OfflineManagerState.loading: VerticalLayout {
|
|
alignment: center;
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
LoadingSpinner { }
|
|
}
|
|
}
|
|
if !OfflineManagerState.loading && OfflineManagerState.rows.length == 0: VerticalLayout {
|
|
alignment: center;
|
|
Text {
|
|
text: @tr("No offline tracks yet");
|
|
color: Theme.text-muted;
|
|
font-size: Typography.body;
|
|
horizontal-alignment: center;
|
|
}
|
|
}
|
|
if !OfflineManagerState.loading && OfflineManagerState.rows.length > 0: ScrollView {
|
|
// Scroll-position restore on back/forward (see nav::scope_for).
|
|
property <string> sr-armed: NavState.restore-scope;
|
|
function sr-restore() {
|
|
if (NavState.restore-scope == "offline-manager" && self.viewport-height > self.visible-height) {
|
|
self.viewport-y = NavState.scroll-restore;
|
|
NavState.restore-scope = "";
|
|
}
|
|
}
|
|
init => { self.sr-restore(); }
|
|
changed sr-armed => { self.sr-restore(); }
|
|
changed viewport-height => { self.sr-restore(); }
|
|
changed viewport-y => { NavState.report-scroll(self.viewport-y); }
|
|
VerticalLayout {
|
|
spacing: 2px;
|
|
for row in OfflineManagerState.rows: Rectangle {
|
|
height: row.kind == "album" ? 60px : 44px;
|
|
border-radius: 8px;
|
|
background: row.kind == "album" ? Theme.surface-card : transparent;
|
|
HorizontalLayout {
|
|
padding-left: row.kind == "album" ? 10px : 16px;
|
|
padding-right: 12px;
|
|
spacing: 12px;
|
|
// Selection checkbox (track rows) / spacer (albums).
|
|
VerticalLayout {
|
|
alignment: center;
|
|
Rectangle {
|
|
width: 16px;
|
|
height: 16px;
|
|
border-radius: 4px;
|
|
background: row.selected ? Theme.accent : transparent;
|
|
border-width: (row.kind == "track" && !row.selected) ? 1.5px : 0px;
|
|
border-color: Theme.text-muted;
|
|
visible: row.kind == "track";
|
|
QbzIcon {
|
|
source: @image-url("../assets/icons/check.svg");
|
|
width: 10px;
|
|
height: 10px;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
tint: #ffffff;
|
|
visible: row.selected;
|
|
}
|
|
TouchArea {
|
|
mouse-cursor: pointer;
|
|
clicked => {
|
|
OfflineManagerActions.toggle-select(row.track-id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Leading — album cover OR track number.
|
|
VerticalLayout {
|
|
alignment: center;
|
|
if row.kind == "album": Rectangle {
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 4px;
|
|
clip: true;
|
|
background: Theme.surface-main;
|
|
Image {
|
|
width: 100%;
|
|
height: 100%;
|
|
source: row.cover;
|
|
image-fit: cover;
|
|
}
|
|
}
|
|
if row.kind == "track": Rectangle {
|
|
width: 40px;
|
|
height: 40px;
|
|
Text {
|
|
width: 100%;
|
|
height: 100%;
|
|
text: row.number;
|
|
color: Theme.text-muted;
|
|
font-size: Typography.body;
|
|
horizontal-alignment: center;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
}
|
|
// Title + subtitle.
|
|
VerticalLayout {
|
|
alignment: center;
|
|
horizontal-stretch: 1;
|
|
spacing: 2px;
|
|
Text {
|
|
text: row.title;
|
|
color: Theme.text-primary;
|
|
font-size: row.kind == "album" ? Typography.body : Typography.legal;
|
|
font-weight: row.kind == "album" ? Typography.semibold : Typography.regular;
|
|
overflow: elide;
|
|
}
|
|
Text {
|
|
text: row.subtitle;
|
|
color: Theme.text-muted;
|
|
font-size: Typography.legal;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
// Meta.
|
|
VerticalLayout {
|
|
alignment: center;
|
|
Text {
|
|
text: row.meta;
|
|
color: Theme.text-muted;
|
|
font-size: Typography.legal;
|
|
horizontal-alignment: right;
|
|
}
|
|
}
|
|
// Re-download.
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconBtn {
|
|
icon: @image-url("../assets/icons/refresh-cw.svg");
|
|
clicked => {
|
|
if (row.kind == "album") {
|
|
OfflineManagerActions.redownload-album(row.album-id);
|
|
} else {
|
|
OfflineManagerActions.redownload-track(row.track-id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Remove.
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconBtn {
|
|
icon: @image-url("../assets/icons/trash-2.svg");
|
|
clicked => {
|
|
if (row.kind == "album") {
|
|
OfflineManagerActions.remove-album(row.album-id);
|
|
} else {
|
|
OfflineManagerActions.remove-track(row.track-id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Status — at the end of the row (both kinds).
|
|
VerticalLayout {
|
|
alignment: center;
|
|
StatusIcon {
|
|
status: row.status;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|