Wires qbz-library into the Slint app (new library_db module) so the
local, Tauri-shared organization data is read/written from the same
per-user library.db (<data_dir>/qbz/users/<id>/library.db). The DB is
opened per-operation on a blocking thread (rusqlite Connection is
!Send).
- Header collage: the playlist cover is now a 4-up collage of the
first tracks' covers (Tauri parity); falls back to the server
image, then the first track, then a placeholder.
- Custom artwork: owner-only buttons on the cover set/clear a custom
image. Set copies the picked file into <cache_dir>/qbz/artwork and
stores the path in playlist_settings.custom_artwork_path (shared
with Tauri); it's loaded directly from disk and overrides the
collage.
- Edit description: the edit modal gains a description field
(prefilled), saved through update_playlist alongside the name.
cc
144 lines
5.8 KiB
Plaintext
144 lines
5.8 KiB
Plaintext
// "Edit playlist" modal — rename + delete. Opened from the playlist
|
|
// detail header's edit button (EditPlaylistState.open).
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { EditPlaylistState, EditPlaylistActions } from "../state.slint";
|
|
import { QbzIcon } from "QbzIcon.slint";
|
|
import { LineEdit, TextEdit } from "std-widgets.slint";
|
|
|
|
export component EditPlaylistModal inherits Rectangle {
|
|
visible: EditPlaylistState.open;
|
|
|
|
if EditPlaylistState.open: Rectangle {
|
|
background: #000000bf;
|
|
TouchArea {
|
|
mouse-cursor: default;
|
|
clicked => {
|
|
EditPlaylistActions.close();
|
|
}
|
|
}
|
|
Rectangle {
|
|
width: Math.min(root.width - 80px, 420px);
|
|
height: panel.preferred-height;
|
|
x: (parent.width - self.width) / 2;
|
|
y: (parent.height - self.height) / 2;
|
|
border-radius: Radius.md;
|
|
background: Theme.surface-card;
|
|
border-width: 1px;
|
|
border-color: Theme.border-subtle;
|
|
drop-shadow-blur: 32px;
|
|
drop-shadow-color: #00000080;
|
|
TouchArea { }
|
|
|
|
panel := VerticalLayout {
|
|
padding: 20px;
|
|
spacing: 16px;
|
|
|
|
HorizontalLayout {
|
|
Text {
|
|
text: @tr("Edit playlist");
|
|
color: Theme.text-primary;
|
|
font-size: Typography.heading;
|
|
font-weight: Typography.semibold;
|
|
horizontal-stretch: 1;
|
|
vertical-alignment: center;
|
|
}
|
|
close-x := TouchArea {
|
|
width: 28px;
|
|
height: 28px;
|
|
mouse-cursor: pointer;
|
|
clicked => {
|
|
EditPlaylistActions.close();
|
|
}
|
|
QbzIcon {
|
|
source: @image-url("../assets/icons/x.svg");
|
|
width: 17px;
|
|
height: 17px;
|
|
x: (parent.width - self.width) / 2;
|
|
y: (parent.height - self.height) / 2;
|
|
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
|
|
}
|
|
}
|
|
}
|
|
|
|
name-input := LineEdit {
|
|
placeholder-text: @tr("Playlist name");
|
|
text <=> EditPlaylistState.name;
|
|
accepted => {
|
|
EditPlaylistActions.save();
|
|
}
|
|
}
|
|
|
|
Text {
|
|
text: @tr("Description");
|
|
color: Theme.text-muted;
|
|
font-size: Typography.legal;
|
|
}
|
|
desc-input := TextEdit {
|
|
height: 90px;
|
|
wrap: word-wrap;
|
|
text <=> EditPlaylistState.description;
|
|
}
|
|
|
|
HorizontalLayout {
|
|
spacing: 10px;
|
|
// Delete (destructive, left).
|
|
Rectangle {
|
|
width: del-label.preferred-width + 28px;
|
|
height: 36px;
|
|
border-radius: Radius.sm;
|
|
background: del-ta.has-hover ? #ef444433 : transparent;
|
|
border-width: 1px;
|
|
border-color: #ef4444;
|
|
del-label := Text {
|
|
text: @tr("Delete");
|
|
color: #ef4444;
|
|
font-size: Typography.body;
|
|
font-weight: Typography.medium;
|
|
x: (parent.width - self.width) / 2;
|
|
y: (parent.height - self.height) / 2;
|
|
}
|
|
del-ta := TouchArea {
|
|
mouse-cursor: EditPlaylistState.busy ? default : pointer;
|
|
clicked => {
|
|
if (!EditPlaylistState.busy) {
|
|
EditPlaylistActions.delete();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Spacer.
|
|
Rectangle { horizontal-stretch: 1; }
|
|
// Save (right).
|
|
Rectangle {
|
|
width: save-label.preferred-width + 36px;
|
|
height: 36px;
|
|
border-radius: Radius.sm;
|
|
opacity: (EditPlaylistState.name != "" && !EditPlaylistState.busy) ? 1.0 : 0.5;
|
|
background: save-ta.has-hover ? #ffffffd6 : Theme.accent;
|
|
save-label := Text {
|
|
text: @tr("Save");
|
|
color: #ffffff;
|
|
font-size: Typography.body;
|
|
font-weight: Typography.semibold;
|
|
x: (parent.width - self.width) / 2;
|
|
y: (parent.height - self.height) / 2;
|
|
}
|
|
save-ta := TouchArea {
|
|
mouse-cursor: (EditPlaylistState.name != "" && !EditPlaylistState.busy)
|
|
? pointer : default;
|
|
clicked => {
|
|
if (EditPlaylistState.name != "" && !EditPlaylistState.busy) {
|
|
EditPlaylistActions.save();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|