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>
190 lines
6.7 KiB
QML
190 lines
6.7 KiB
QML
pragma ComponentBehavior: Bound
|
||
import QtQuick
|
||
import QtQuick.Layouts
|
||
import "../components"
|
||
import "../services"
|
||
import "../theme"
|
||
|
||
GlassPanel {
|
||
id: root
|
||
objectName: "mediaCard"
|
||
property bool compact: false
|
||
readonly property bool showProgress: ConfigService.ready && ConfigService.data.media.showProgress
|
||
implicitWidth: compact ? 340 : 480
|
||
implicitHeight: body.implicitHeight + 36
|
||
Demand {
|
||
service: MediaService
|
||
counter: "progressConsumers"
|
||
active: root.visible && root.showProgress
|
||
}
|
||
Connections {
|
||
target: MediaService
|
||
function onTitleChanged() {
|
||
if (root.visible && Theme.duration > 0)
|
||
transition.restart();
|
||
}
|
||
}
|
||
ParallelAnimation {
|
||
id: transition
|
||
NumberAnimation {
|
||
target: metadata
|
||
property: "opacity"
|
||
from: 0.55
|
||
to: 1
|
||
duration: Theme.duration
|
||
}
|
||
NumberAnimation {
|
||
target: movement
|
||
property: "y"
|
||
from: 5 * Theme.intensity
|
||
to: 0
|
||
duration: Theme.duration
|
||
easing.type: Easing.OutCubic
|
||
}
|
||
}
|
||
ColumnLayout {
|
||
id: body
|
||
anchors {
|
||
left: parent.left
|
||
right: parent.right
|
||
top: parent.top
|
||
margins: 18
|
||
}
|
||
spacing: 10
|
||
RowLayout {
|
||
spacing: 16
|
||
Rectangle {
|
||
visible: ConfigService.ready && ConfigService.data.media.showAlbumArt
|
||
Layout.preferredWidth: root.compact ? 64 : 112
|
||
Layout.preferredHeight: width
|
||
radius: 12
|
||
color: Theme.surfaceVariant
|
||
clip: true
|
||
Text {
|
||
anchors.centerIn: parent
|
||
text: "♫"
|
||
font.pixelSize: 34
|
||
color: Theme.textSecondary
|
||
visible: art.status !== Image.Ready
|
||
}
|
||
Image {
|
||
id: art
|
||
anchors.fill: parent
|
||
source: MediaService.artwork
|
||
sourceSize.width: 256
|
||
sourceSize.height: 256
|
||
asynchronous: true
|
||
retainWhileLoading: true
|
||
fillMode: Image.PreserveAspectCrop
|
||
opacity: status === Image.Ready ? 1 : 0
|
||
Behavior on opacity {
|
||
NumberAnimation {
|
||
duration: Theme.duration
|
||
}
|
||
}
|
||
}
|
||
}
|
||
ColumnLayout {
|
||
id: metadata
|
||
transform: Translate {
|
||
id: movement
|
||
}
|
||
Layout.fillWidth: true
|
||
spacing: 5
|
||
Text {
|
||
text: MediaService.title
|
||
color: Theme.text
|
||
font.pixelSize: root.compact ? 15 : 19
|
||
font.weight: Font.DemiBold
|
||
elide: Text.ElideRight
|
||
Layout.fillWidth: true
|
||
}
|
||
Text {
|
||
text: MediaService.artist
|
||
color: Theme.textSecondary
|
||
font.pixelSize: 13
|
||
elide: Text.ElideRight
|
||
Layout.fillWidth: true
|
||
}
|
||
Text {
|
||
visible: !root.compact && ConfigService.ready && ConfigService.data.media.showAlbum && !!text
|
||
text: MediaService.album
|
||
color: Theme.textSecondary
|
||
elide: Text.ElideRight
|
||
Layout.fillWidth: true
|
||
}
|
||
RowLayout {
|
||
GlassButton {
|
||
objectName: "mediaPrevious"
|
||
text: "⏮"
|
||
enabled: !!MediaService.player && MediaService.player.canControl && MediaService.player.canGoPrevious
|
||
onClicked: MediaService.previous()
|
||
Accessible.name: "Previous track"
|
||
}
|
||
GlassButton {
|
||
objectName: "mediaToggle"
|
||
text: MediaService.playing ? "Ⅱ" : "▶"
|
||
accented: true
|
||
enabled: !!MediaService.player && MediaService.player.canControl && MediaService.player.canTogglePlaying
|
||
onClicked: MediaService.toggle()
|
||
Accessible.name: MediaService.playing ? "Pause" : "Play"
|
||
}
|
||
GlassButton {
|
||
objectName: "mediaNext"
|
||
text: "⏭"
|
||
enabled: !!MediaService.player && MediaService.player.canControl && MediaService.player.canGoNext
|
||
onClicked: MediaService.next()
|
||
Accessible.name: "Next track"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
RowLayout {
|
||
visible: root.showProgress && MediaService.length > 0
|
||
Text {
|
||
text: MediaService.time(MediaService.position)
|
||
color: Theme.textSecondary
|
||
font.pixelSize: 11
|
||
}
|
||
GlassSlider {
|
||
Layout.fillWidth: true
|
||
from: 0
|
||
to: Math.max(1, MediaService.length)
|
||
value: MediaService.position
|
||
enabled: MediaService.seekable
|
||
onMoved: MediaService.seek(value)
|
||
Accessible.name: "Track position"
|
||
}
|
||
Text {
|
||
text: "−" + MediaService.time(MediaService.length - MediaService.position)
|
||
color: Theme.textSecondary
|
||
font.pixelSize: 11
|
||
}
|
||
}
|
||
GlassComboBox {
|
||
visible: MediaService.players.length > 1
|
||
Layout.fillWidth: true
|
||
model: MediaService.players.map(p => ({
|
||
name: p.identity || p.dbusName,
|
||
id: p.dbusName
|
||
}))
|
||
textRole: "name"
|
||
currentIndex: MediaService.players.indexOf(MediaService.player)
|
||
onActivated: MediaService.choose(MediaService.players[currentIndex].dbusName)
|
||
Accessible.name: "Media player"
|
||
}
|
||
CavaView {
|
||
Layout.fillWidth: true
|
||
visible: ConfigService.ready && ConfigService.data.media.showCava
|
||
}
|
||
Text {
|
||
visible: !!CavaService.error && ConfigService.ready && ConfigService.data.media.showCava
|
||
text: CavaService.error
|
||
color: Theme.textSecondary
|
||
wrapMode: Text.Wrap
|
||
Layout.fillWidth: true
|
||
font.pixelSize: 11
|
||
}
|
||
}
|
||
}
|