Add services/Demand.qml, which holds one count on a service's demand counter while active. It replaces 13 hand-written consumer counters across the bar, Control Center, dashboard, media and desktop widgets. The desktop Cava widget now releases Cava while its desktop is covered. Add components/JumpValue.qml for the "animate only visible jumps" rule shared by the dashboard gauge and resource bars. Move the Settings sidebar (search and navigation) into settings/SettingsSidebar.qml and the drag handle into settings/controls/SettingsDragArea.qml, halving Settings.qml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
2.8 KiB
QML
86 lines
2.8 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import "../../components"
|
|
import "../../core"
|
|
import "../../services"
|
|
import "../../theme"
|
|
|
|
// Cava audio visualizer in the bar. Click opens the dashboard's Media tab,
|
|
// right-click the Media settings. Cava only runs while something plays.
|
|
GlassPill {
|
|
id: root
|
|
objectName: "cavaPill"
|
|
readonly property var options: ConfigService.ready ? ConfigService.data.bar.cava : ({
|
|
bars: 12,
|
|
style: "bars",
|
|
hideWhenIdle: true
|
|
})
|
|
readonly property bool mirror: options.style === "mirror"
|
|
readonly property bool shown: !CavaService.failed && (MediaService.playing || !options.hideWhenIdle)
|
|
readonly property int barWidth: 3
|
|
readonly property int gap: 2
|
|
implicitHeight: ModuleRegistry.pillHeight
|
|
implicitWidth: shown ? options.bars * barWidth + (options.bars - 1) * gap + 22 : 0
|
|
visible: implicitWidth > 0.5
|
|
opacity: shown ? 1 : 0
|
|
clip: true
|
|
Behavior on implicitWidth {
|
|
NumberAnimation {
|
|
duration: Theme.duration * 1.4
|
|
easing.type: Easing.OutCubic
|
|
}
|
|
}
|
|
Behavior on opacity {
|
|
NumberAnimation {
|
|
duration: Theme.duration
|
|
}
|
|
}
|
|
Demand {
|
|
service: CavaService
|
|
counter: "widgetConsumers"
|
|
}
|
|
// Cava emits 24 bands; each pill bar averages its share of them.
|
|
function level(index) {
|
|
const all = CavaService.bars, n = options.bars, from = Math.floor(index * all.length / n), to = Math.max(from + 1, Math.floor((index + 1) * all.length / n));
|
|
let sum = 0;
|
|
for (let i = from; i < to; i++)
|
|
sum += all[i] || 0;
|
|
return sum / (to - from);
|
|
}
|
|
Row {
|
|
anchors.centerIn: parent
|
|
height: parent.height - 12
|
|
spacing: root.gap
|
|
Repeater {
|
|
model: root.options.bars
|
|
Rectangle {
|
|
required property int index
|
|
readonly property real value: MediaService.playing ? Math.min(1, root.level(index)) : 0
|
|
width: root.barWidth
|
|
radius: width / 2
|
|
height: Math.max(width, parent.height * value)
|
|
y: root.mirror ? (parent.height - height) / 2 : parent.height - height
|
|
color: Theme.accentVivid
|
|
opacity: 0.55 + 0.45 * value
|
|
Behavior on height {
|
|
NumberAnimation {
|
|
duration: 80
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
TapHandler {
|
|
acceptedButtons: Qt.LeftButton
|
|
onTapped: ShellState.toggleDashboard("media")
|
|
}
|
|
TapHandler {
|
|
acceptedButtons: Qt.RightButton
|
|
onTapped: ShellState.openSettings("media")
|
|
}
|
|
HoverHandler {
|
|
cursorShape: Qt.PointingHandCursor
|
|
}
|
|
Accessible.name: "Audio visualizer"
|
|
}
|