Top-left under the rail: whether the mic is open, whether she is thinking, and whether she is talking — the states a 5s reply makes you want to see. No avatar yet; the meter is a placeholder for it, and the states and their colours are the part that has to read correctly first. LunaIndicator is Item-rooted so render.sh can shoot all five states offscreen (tests/LunaIndicatorHeadless.qml); LunaCall is the thin PanelWindow. Beside the notification stack rather than among the modals: it never takes the keyboard and raises no scrim, so it is deliberately absent from `modalOpen`. LunaState is read-only — the toggle runs the CLI — and treats a missing socket as normal, since the daemon is a user service that may start after the shell or not be installed at all. Two things measurement decided rather than reasoning. ExclusionMode .Ignore put it OVER the bar (it ignores other surfaces' zones, not just its own), and switching to Normal was not enough either: the rail's exclusive zone still left it at y=8 against a bar occupying 0..147. So the shell passes bar.contentHeight down, the same value the backdrop already reads. And the card is one chamfered path rather than a rectangle with a triangle over its corner, which left the square border showing underneath and read as an artifact. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
230 lines
7.9 KiB
QML
230 lines
7.9 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import QtQuick.Shapes
|
|
import qs.HyprChrome.Theme
|
|
|
|
// The voice-mode readout: whether luna is listening, thinking or talking.
|
|
//
|
|
// Item-rooted with no window of its own so tools/quickshell-preview/render.sh
|
|
// can shoot it offscreen — the PanelWindow lives in LunaCall.qml. A standalone
|
|
// 3D avatar replaces the meter later; the states and their colours are the
|
|
// part that has to read correctly first.
|
|
Item {
|
|
id: root
|
|
|
|
// Driven by LunaState; defaulted so the headless render and the
|
|
// DebugWindow can stage this without a daemon.
|
|
property string state: "idle"
|
|
property bool active: true
|
|
property bool connected: true
|
|
property real rms: 0
|
|
property string userText: ""
|
|
property string lunaText: ""
|
|
|
|
// Metrics are per-component in this tree; Theme carries colour and type only.
|
|
readonly property int pad: 8
|
|
readonly property int chamfer: 10
|
|
|
|
implicitWidth: 260
|
|
implicitHeight: content.implicitHeight + root.pad * 2
|
|
|
|
// Not readonly: a Behavior cannot attach to a readonly property, and the
|
|
// colour crossfade is what keeps state changes from snapping.
|
|
property color stateColor: {
|
|
if (!root.connected)
|
|
return Theme.disabled;
|
|
switch (root.state) {
|
|
case "listening":
|
|
return Theme.accent;
|
|
case "thinking":
|
|
return Theme.muted;
|
|
case "speaking":
|
|
return Theme.accentSoft;
|
|
default:
|
|
return Theme.raised;
|
|
}
|
|
}
|
|
|
|
readonly property string stateLabel: {
|
|
if (!root.connected)
|
|
return "OFFLINE";
|
|
switch (root.state) {
|
|
case "listening":
|
|
return "LISTENING";
|
|
case "thinking":
|
|
return "THINKING";
|
|
case "speaking":
|
|
return "SPEAKING";
|
|
default:
|
|
return "READY";
|
|
}
|
|
}
|
|
|
|
Behavior on stateColor {
|
|
ColorAnimation { duration: 180 }
|
|
}
|
|
|
|
// The card is ONE chamfered path, not a rectangle with a triangle drawn
|
|
// over its corner — that leaves the square border showing underneath and
|
|
// reads as an artifact rather than a cut.
|
|
Shape {
|
|
anchors.fill: parent
|
|
preferredRendererType: Shape.CurveRenderer
|
|
opacity: 0.96
|
|
|
|
ShapePath {
|
|
strokeWidth: 1
|
|
strokeColor: root.stateColor
|
|
fillColor: Theme.surface
|
|
startX: 0
|
|
startY: 0
|
|
PathLine { x: root.width - root.chamfer; y: 0 }
|
|
PathLine { x: root.width; y: root.chamfer }
|
|
PathLine { x: root.width; y: root.height }
|
|
PathLine { x: 0; y: root.height }
|
|
PathLine { x: 0; y: 0 }
|
|
}
|
|
}
|
|
|
|
Column {
|
|
id: content
|
|
anchors.fill: parent
|
|
anchors.margins: root.pad
|
|
spacing: root.pad
|
|
|
|
Row {
|
|
spacing: root.pad
|
|
|
|
// The one element that is alive while nothing else moves: a dot
|
|
// that breathes in listening and holds steady otherwise, so "the
|
|
// mic is open" is legible from across the room.
|
|
Rectangle {
|
|
id: dot
|
|
width: 8
|
|
height: 8
|
|
radius: 4
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
color: root.stateColor
|
|
|
|
SequentialAnimation on opacity {
|
|
running: root.state === "listening"
|
|
loops: Animation.Infinite
|
|
alwaysRunToEnd: true
|
|
NumberAnimation { to: 0.25; duration: 700; easing.type: Easing.InOutQuad }
|
|
NumberAnimation { to: 1.0; duration: 700; easing.type: Easing.InOutQuad }
|
|
}
|
|
// An animation that stops mid-fade would leave the dot dim
|
|
// and looking half-dead.
|
|
onVisibleChanged: if (root.state !== "listening") opacity = 1
|
|
}
|
|
|
|
Text {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: "LUNA"
|
|
color: Theme.text
|
|
font.family: Theme.displayFont
|
|
font.pixelSize: 12
|
|
font.letterSpacing: 2
|
|
}
|
|
|
|
Text {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: root.stateLabel
|
|
color: root.stateColor
|
|
font.family: Theme.microFont
|
|
font.pixelSize: 10
|
|
font.letterSpacing: 1
|
|
}
|
|
}
|
|
|
|
// Level meter. Bars react to rms while listening or speaking; during
|
|
// thinking they run a sweep instead, because a dead meter and a
|
|
// crashed daemon look identical and her replies take seconds.
|
|
Row {
|
|
id: meter
|
|
width: parent.width
|
|
height: 22
|
|
spacing: 2
|
|
|
|
readonly property int count: 24
|
|
readonly property bool sweeping: root.state === "thinking"
|
|
property real phase: 0
|
|
|
|
NumberAnimation on phase {
|
|
running: meter.sweeping
|
|
loops: Animation.Infinite
|
|
from: 0
|
|
to: 1
|
|
duration: 1200
|
|
}
|
|
|
|
Repeater {
|
|
model: meter.count
|
|
|
|
Rectangle {
|
|
required property int index
|
|
|
|
width: (meter.width - (meter.count - 1) * meter.spacing) / meter.count
|
|
height: {
|
|
if (meter.sweeping) {
|
|
// A travelling bump rather than a bar graph.
|
|
const pos = index / (meter.count - 1);
|
|
const d = Math.abs(pos - meter.phase);
|
|
return 3 + 16 * Math.max(0, 1 - d * 6);
|
|
}
|
|
// Live whenever voice mode is on, not only once a
|
|
// trigger has fired: "is it hearing me at all" has to
|
|
// be answerable BEFORE anything happens, or a mic
|
|
// that is too quiet looks exactly like a broken one.
|
|
if (!root.active && root.state !== "speaking")
|
|
return 3;
|
|
// rms is small and non-linear; sqrt opens up the
|
|
// quiet end where speech actually sits.
|
|
const level = Math.min(1, Math.sqrt(root.rms) * 3.2);
|
|
// Centre bars taller, so it reads as a voice rather
|
|
// than a progress bar.
|
|
const centre = 1 - Math.abs(index / (meter.count - 1) - 0.5) * 1.6;
|
|
return 3 + 19 * level * Math.max(0.15, centre);
|
|
}
|
|
anchors.bottom: parent.bottom
|
|
color: root.stateColor
|
|
opacity: meter.sweeping ? 0.9 : 0.55 + 0.45 * (height / 22)
|
|
|
|
Behavior on height {
|
|
enabled: !meter.sweeping
|
|
NumberAnimation { duration: 70; easing.type: Easing.OutQuad }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Captions: hers leads the audio (the daemon emits each sentence as
|
|
// it goes to the synthesiser), which is what makes a 5s reply feel
|
|
// like it has started.
|
|
Text {
|
|
width: parent.width
|
|
visible: root.userText !== ""
|
|
text: `> ${root.userText}`
|
|
color: Theme.muted
|
|
font.family: Theme.microFont
|
|
font.pixelSize: 10
|
|
wrapMode: Text.WordWrap
|
|
maximumLineCount: 2
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Text {
|
|
width: parent.width
|
|
visible: root.lunaText !== ""
|
|
text: root.lunaText
|
|
color: Theme.text
|
|
font.family: Theme.microFont
|
|
font.pixelSize: 11
|
|
wrapMode: Text.WordWrap
|
|
maximumLineCount: 3
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
}
|