- Appearance: drop the red 'unsupported' tint on Language; hide UI Scale and
the Title Bar / Window Controls / Immersive blocks (commented, not deleted).
- Window title: "Show track in window title" now works -- the OS window title
becomes "{track} - {artist} | qbz" via a reactive binding (editable template
row hidden; format is fixed).
- Plex and Scrobblers collapse carets enlarged (28/18) and moved to row level so
they are vertically centered with the master toggle.
- Hamburger: "Open Qobuz Link" -> "Open Music Link".
- Link modal: a long pasted URL no longer grows the input/modal (min-width 0 on
the clip container caps content-width propagation).
cc
291 lines
15 KiB
Plaintext
291 lines
15 KiB
Plaintext
// "Open Qobuz Link" modal — 1:1 with Tauri's LinkResolverModal.svelte.
|
|
//
|
|
// Triggered by Ctrl+L (gate: LinkResolverState.open). Paste a Qobuz /
|
|
// Spotify / Apple Music / Tidal / Deezer / song.link URL, hit Go, and the
|
|
// controller resolves it to an album/track/artist/playlist and navigates.
|
|
// A playlist link surfaces a banner that hands off to the Playlist Importer.
|
|
//
|
|
// Layout (mirrors the Svelte source):
|
|
// [ platform icon 36x36 ][ url input (stretch) ][ Go button ]
|
|
// error text line (red, when error != "")
|
|
// playlist banner (when playlist-detected): text + "Open Playlist Importer"
|
|
//
|
|
// The url field sets UiFocusState.text-input-focused on `changed has-focus`
|
|
// so single-key global hotkeys don't fire while the user types a URL.
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { Spacing } from "../foundation/spacing.slint";
|
|
import { LinkResolverState, LinkResolverActions, UiFocusState } from "../state.slint";
|
|
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
|
|
|
export component LinkResolverModal inherits Rectangle {
|
|
width: 100%;
|
|
height: 100%;
|
|
visible: LinkResolverState.open;
|
|
|
|
if LinkResolverState.open: Rectangle {
|
|
// Scrim — click-outside closes.
|
|
background: #000000bf;
|
|
TouchArea {
|
|
mouse-cursor: default;
|
|
clicked => {
|
|
LinkResolverActions.close();
|
|
}
|
|
}
|
|
|
|
// Card-sized FocusScope so Escape closes and the input can grab
|
|
// focus on (deferred) mount. Locals live on the `if open:` subtree
|
|
// so each remount resets cleanly.
|
|
keys := FocusScope {
|
|
width: Math.min(root.width - 80px, 520px);
|
|
height: panel.preferred-height;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
forward-focus: url-input;
|
|
|
|
key-pressed(event) => {
|
|
if (event.text == Key.Escape) {
|
|
LinkResolverActions.close();
|
|
return accept;
|
|
}
|
|
return reject;
|
|
}
|
|
|
|
// Deferred mount focus — synchronous focus during the remount
|
|
// races layout; a one-shot timer grabs it a tick later.
|
|
focus-timer := Timer {
|
|
interval: 30ms;
|
|
running: true;
|
|
triggered => {
|
|
self.running = false;
|
|
keys.focus();
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
border-radius: Radius.md;
|
|
background: Theme.surface-card;
|
|
border-width: 1px;
|
|
border-color: Theme.border-subtle;
|
|
drop-shadow-blur: 32px;
|
|
drop-shadow-color: #00000080;
|
|
// Block scrim click-through.
|
|
TouchArea { }
|
|
|
|
panel := VerticalLayout {
|
|
padding: Spacing.lg;
|
|
spacing: Spacing.md;
|
|
|
|
// Header: title + close X.
|
|
HorizontalLayout {
|
|
Text {
|
|
text: @tr("Open Qobuz Link");
|
|
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 => {
|
|
LinkResolverActions.close();
|
|
}
|
|
QbzIcon {
|
|
source: @image-url("../assets/icons/x.svg");
|
|
width: 17px;
|
|
height: 17px;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Input row: [platform icon][url input][Go].
|
|
HorizontalLayout {
|
|
spacing: Spacing.sm;
|
|
|
|
// Leading platform glyph — 36x36 slot, 24x24 logo.
|
|
// The image is picked from LinkResolverState.platform,
|
|
// which Rust sets on url-changed. song.link and the
|
|
// empty/unknown case fall back to the generic link
|
|
// icon (Tauri shows a Link2 lucide glyph for songlink
|
|
// and nothing for unknown; a quiet link icon reads the
|
|
// same and keeps the row width stable).
|
|
Rectangle {
|
|
width: 36px;
|
|
height: 36px;
|
|
QbzIcon {
|
|
width: 24px;
|
|
height: 24px;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
// Tint only the generic fallback link icon; the
|
|
// brand logos are full-color SVGs and must NOT
|
|
// be recolored.
|
|
tint: (LinkResolverState.platform == "qobuz"
|
|
|| LinkResolverState.platform == "spotify"
|
|
|| LinkResolverState.platform == "apple"
|
|
|| LinkResolverState.platform == "tidal"
|
|
|| LinkResolverState.platform == "deezer")
|
|
? transparent : Theme.text-muted;
|
|
source:
|
|
LinkResolverState.platform == "qobuz"
|
|
? @image-url("../assets/icons/qobuz-logo.svg")
|
|
: LinkResolverState.platform == "spotify"
|
|
? @image-url("../assets/icons/spotify-logo.svg")
|
|
: LinkResolverState.platform == "apple"
|
|
? @image-url("../assets/icons/apple-music-logo.svg")
|
|
: LinkResolverState.platform == "tidal"
|
|
? @image-url("../assets/icons/tidal-tidal.svg")
|
|
: LinkResolverState.platform == "deezer"
|
|
? @image-url("../assets/icons/deezer-logo.svg")
|
|
: @image-url("../assets/icons/link.svg");
|
|
}
|
|
}
|
|
|
|
// URL input — custom box (not LineEdit) so we own the
|
|
// focus guard + placeholder + disabled styling.
|
|
input-box := Rectangle {
|
|
horizontal-stretch: 1;
|
|
height: 40px;
|
|
border-radius: Radius.sm;
|
|
background: Theme.surface-elevated;
|
|
border-width: 1px;
|
|
border-color: url-input.has-focus ? Theme.accent : Theme.border-subtle;
|
|
opacity: LinkResolverState.resolving ? 0.6 : 1.0;
|
|
HorizontalLayout {
|
|
padding-left: 14px;
|
|
padding-right: 14px;
|
|
Rectangle {
|
|
horizontal-stretch: 1;
|
|
clip: true;
|
|
// Cap the layout participant too so a long
|
|
// URL can't claim width up the chain.
|
|
min-width: 0px;
|
|
url-input := TextInput {
|
|
width: 100%;
|
|
height: 100%;
|
|
color: Theme.text-primary;
|
|
font-size: Typography.link;
|
|
vertical-alignment: center;
|
|
single-line: true;
|
|
enabled: !LinkResolverState.resolving;
|
|
// Two-way bound; `edited` additionally
|
|
// fires live platform detection.
|
|
text <=> LinkResolverState.url;
|
|
edited => {
|
|
LinkResolverActions.url-changed(self.text);
|
|
}
|
|
accepted => {
|
|
LinkResolverActions.submit(LinkResolverState.url);
|
|
}
|
|
// REQUIRED: gate single-key hotkeys
|
|
// while typing a URL.
|
|
changed has-focus => {
|
|
UiFocusState.text-input-focused = self.has-focus;
|
|
}
|
|
}
|
|
// Placeholder — TextInput has no native
|
|
// placeholder; a sibling Text gated on empty.
|
|
Text {
|
|
visible: url-input.text == "";
|
|
width: 100%;
|
|
height: 100%;
|
|
text: @tr("Paste a Qobuz, Spotify, Apple Music, Tidal, Deezer or song.link URL");
|
|
color: Theme.text-muted;
|
|
font-size: Typography.link;
|
|
vertical-alignment: center;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Go button — disabled while resolving or url empty.
|
|
Rectangle {
|
|
property <bool> can-go: LinkResolverState.url != "" && !LinkResolverState.resolving;
|
|
width: go-label.preferred-width + 40px;
|
|
height: 40px;
|
|
border-radius: Radius.sm;
|
|
opacity: self.can-go ? 1.0 : 0.5;
|
|
background: go-ta.has-hover && self.can-go ? Theme.accent-hover : Theme.accent;
|
|
go-label := Text {
|
|
text: LinkResolverState.resolving ? @tr("Resolving…") : @tr("Go");
|
|
color: Theme.accent-text;
|
|
font-size: Typography.body;
|
|
font-weight: Typography.semibold;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
}
|
|
go-ta := TouchArea {
|
|
mouse-cursor: parent.can-go ? pointer : default;
|
|
clicked => {
|
|
if (parent.can-go) {
|
|
LinkResolverActions.submit(LinkResolverState.url);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Error line.
|
|
if LinkResolverState.error != "": Text {
|
|
text: LinkResolverState.error;
|
|
color: Theme.danger;
|
|
font-size: Typography.legal;
|
|
wrap: word-wrap;
|
|
}
|
|
|
|
// Playlist banner — hand off to the Playlist Importer.
|
|
if LinkResolverState.playlist-detected: Rectangle {
|
|
height: banner.preferred-height;
|
|
border-radius: Radius.sm;
|
|
background: Theme.surface-elevated;
|
|
border-width: 1px;
|
|
border-color: Theme.border-subtle;
|
|
banner := VerticalLayout {
|
|
padding: 12px;
|
|
spacing: Spacing.sm;
|
|
Text {
|
|
text: @tr("This looks like a playlist.");
|
|
color: Theme.text-secondary;
|
|
font-size: Typography.legal;
|
|
wrap: word-wrap;
|
|
}
|
|
HorizontalLayout {
|
|
alignment: start;
|
|
Rectangle {
|
|
width: importer-label.preferred-width + 32px;
|
|
height: 34px;
|
|
border-radius: Radius.sm;
|
|
background: importer-ta.has-hover ? Theme.accent-hover : Theme.accent;
|
|
importer-label := Text {
|
|
text: @tr("Open Playlist Importer");
|
|
color: Theme.accent-text;
|
|
font-size: Typography.legal;
|
|
font-weight: Typography.semibold;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
}
|
|
importer-ta := TouchArea {
|
|
mouse-cursor: pointer;
|
|
clicked => {
|
|
LinkResolverActions.open-importer();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|