Slint cannot split the .slint compilation across crates, but a Slint LIBRARY crate exposes its generated Rust types to dependent crates (verified with a minimal proof). So: - NEW crate `qbz-ui` (lib): owns the whole .slint tree + build.rs + bundled translations; `slint::include_modules!()` + the generated types (AppWindow, MiniPlayerWindow, all globals/structs) are re-exported. Translation domain is now `qbz-ui` (the .po files renamed accordingly). - `qbz-slint` (bin) -> renamed to `qbz` (package + `[[bin]] name = "qbz"`), reclaiming the binary name from the retired Tauri app. It depends on `qbz-ui` and does `pub use qbz_ui::*;` so existing `crate::AppWindow` / `crate::*State` references resolve unchanged. This splits the single ~20 GB rustc into two crates (UI/codegen vs the 75k LOC of logic) — the foundation for lower build peak, incremental caching, and the upcoming per-feature crate extraction. Also fixed for the move: qbz-i18n bundled-.po include paths, the font/WGSL `include_bytes!`/`include_str!` paths (-> ../../qbz-ui/ui/), workspace members, dev scripts (`-p qbz`), and the CI workflows. `cargo check -p qbz` is green. cc
101 lines
3.5 KiB
Plaintext
101 lines
3.5 KiB
Plaintext
// Multi-select bulk action bar — a "N selected" count label plus a row
|
|
// of action buttons driven by a [BulkAction] model, so the bar's chrome
|
|
// lives in one place. Shared by PlaylistView and the Favorites tracks
|
|
// tab. Emits the chosen action's id via `action(id)`; the surrounding
|
|
// view maps that id to a command. ADR-008: these are bordered/hover
|
|
// buttons, not pills.
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { QbzIcon } from "QbzIcon.slint";
|
|
import { BulkAction, TooltipState } from "../state.slint";
|
|
|
|
// One action button — an ICON with a hover tooltip (the action's label).
|
|
// Borderless hover for a normal action, red-bordered for a danger action,
|
|
// dimmed + non-interactive when it needs a selection and there is none.
|
|
component BulkButton inherits Rectangle {
|
|
in property <image> icon;
|
|
in property <string> tooltip;
|
|
in property <bool> danger: false;
|
|
in property <bool> enabled-when: true;
|
|
callback clicked();
|
|
|
|
width: 34px;
|
|
height: 30px;
|
|
border-radius: Radius.sm;
|
|
opacity: root.enabled-when ? 1.0 : 0.4;
|
|
background: root.danger
|
|
? (ta.has-hover ? Theme.danger-hover : transparent)
|
|
: (ta.has-hover ? Theme.surface-hover : transparent);
|
|
border-width: root.danger ? 1px : 0px;
|
|
border-color: Theme.danger-border;
|
|
|
|
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
|
|
? Theme.danger
|
|
: (ta.has-hover ? Theme.text-primary : Theme.text-secondary);
|
|
}
|
|
|
|
ta := TouchArea {
|
|
mouse-cursor: root.enabled-when ? pointer : default;
|
|
clicked => {
|
|
if (root.enabled-when) {
|
|
root.clicked();
|
|
}
|
|
}
|
|
// Shared tooltip bubble (same channel as CircleAction), so each
|
|
// icon explains itself on hover.
|
|
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 MultiSelectBar inherits Rectangle {
|
|
in property <int> selected-count: 0;
|
|
in property <[BulkAction]> actions;
|
|
callback action(string);
|
|
|
|
height: 44px;
|
|
border-radius: 8px;
|
|
background: Theme.surface-elevated;
|
|
|
|
HorizontalLayout {
|
|
padding-left: 14px;
|
|
padding-right: 10px;
|
|
spacing: 6px;
|
|
Text {
|
|
text: root.selected-count + " " + @tr("selected");
|
|
color: Theme.text-secondary;
|
|
font-size: Typography.body;
|
|
vertical-alignment: center;
|
|
horizontal-stretch: 1;
|
|
}
|
|
for act in root.actions: VerticalLayout {
|
|
alignment: center;
|
|
BulkButton {
|
|
icon: act.icon;
|
|
tooltip: act.label;
|
|
danger: act.danger;
|
|
enabled-when: !act.needs-selection || root.selected-count > 0;
|
|
clicked => {
|
|
root.action(act.id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|