nix/nixos/desktop/quickshell/widgets/Media.qml
Markus Zoppelt 6eef44005c feat: quickshell chrome and session helpers
Add Switch, Btn, and Menu. Share Session and Run.term. Widget skill for agents; no plugin host.
2026-08-29 13:46:57 +02:00

119 lines
3.3 KiB
QML

import QtQuick
import ".."
import "../ui"
Chip {
id: root
visible: Audio.playing
color: Theme.fgDark
text: "󰐊"
tip: {
const p = Audio.player;
return p ? ((p.trackArtist || "") + (p.trackArtist && p.trackTitle ? " — " : "") + (p.trackTitle || p.identity || "ncspot")) : "";
}
onClicked: button => {
const p = Audio.player;
if (!p)
return;
if (button === Qt.RightButton && p.canGoNext)
p.next();
else
panel.toggle(root);
}
PanelCard {
id: panel
paneWidth: 380
Heading {
title: Audio.player?.trackTitle || "Nothing playing"
subtitle: [Audio.player?.trackArtist, Audio.player?.trackAlbum, Audio.player?.identity].filter(Boolean).join(" · ")
}
Item {
visible: !!(Audio.player?.trackArtUrl)
width: parent.width
implicitHeight: 180
Image {
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
source: Fmt.imageUrl(Audio.player?.trackArtUrl, true)
asynchronous: true
cache: false
}
Eq {
values: Audio.eq
anchors.fill: parent
anchors.margins: 8
}
Rectangle {
anchors.fill: parent
color: "transparent"
border.width: 1
border.color: Theme.black
radius: Theme.radius
}
}
Column {
visible: !!(Audio.player?.length)
width: parent.width
spacing: 6
Meter {
width: parent.width
value: Audio.player && Audio.player.length > 0 ? Audio.player.position / Audio.player.length : 0
}
Item {
width: parent.width
implicitHeight: 14
Text {
text: Audio.player ? Fmt.clock(Audio.player.position) : ""
color: Theme.comment
font.family: Theme.font
font.pixelSize: 12
}
Text {
anchors.right: parent.right
text: Audio.player ? Fmt.clock(Audio.player.length) : ""
color: Theme.comment
font.family: Theme.font
font.pixelSize: 12
}
}
}
Row {
width: parent.width
spacing: 8
Btn {
width: (parent.width - 16) / 3
glyph: "󰒮"
enabled: !!Audio.player?.canGoPrevious
onClicked: Audio.player.previous()
}
Btn {
width: (parent.width - 16) / 3
glyph: Audio.player?.isPlaying ? "󰏤" : "󰐊"
kind: "primary"
enabled: !!Audio.player?.canTogglePlaying
onClicked: Audio.player.togglePlaying()
}
Btn {
width: (parent.width - 16) / 3
glyph: "󰒭"
enabled: !!Audio.player?.canGoNext
onClicked: Audio.player.next()
}
}
}
}