Files
glassMxrph/quickshell/media/MediaCard.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

204 lines
7.1 KiB
QML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import "../components"
import "../services"
import "../theme"
GlassPanel {
id: root
objectName: "mediaCard"
property bool compact: false
property bool mounted: false
property bool subscribed: false
readonly property bool showProgress: ConfigService.ready && ConfigService.data.media.showProgress
implicitWidth: compact ? 340 : 480
implicitHeight: body.implicitHeight + 36
function sync() {
const next = mounted && visible && showProgress;
if (next !== subscribed) {
MediaService.progressConsumers += next ? 1 : -1;
subscribed = next;
}
}
Component.onCompleted: {
mounted = true;
sync();
}
Component.onDestruction: {
if (subscribed)
MediaService.progressConsumers--;
}
onVisibleChanged: sync()
onShowProgressChanged: sync()
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
}
}
}