Files
glassMxrph/quickshell/dashboard/tabs/MediaTab.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

283 lines
12 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 Quickshell.Services.Mpris
import Quickshell.Widgets
import ".."
import "../../components"
import "../../services"
import "../../theme"
// Now playing with full transport controls, a Cava strip and the EasyEffects equalizer.
Item {
id: root
property bool current: false
property bool showEqualizer: true
implicitWidth: row.implicitWidth
implicitHeight: row.implicitHeight
readonly property var player: MediaService.player
// Streams report no length or absurd ones; show them as live.
readonly property bool live: MediaService.length <= 0 || MediaService.length > 7 * 86400
property bool subscribed: false
onCurrentChanged: sync()
Component.onCompleted: sync()
Component.onDestruction: if (subscribed) {
MediaService.progressConsumers--;
CavaService.widgetConsumers--;
}
function sync() {
if (current === subscribed)
return;
MediaService.progressConsumers += current ? 1 : -1;
CavaService.widgetConsumers += current ? 1 : -1;
subscribed = current;
if (current)
EasyEffectsService.refresh();
}
RowLayout {
id: row
spacing: 12
DashCard {
id: playerCard
objectName: "dashPlayer"
Layout.preferredWidth: 400
Layout.preferredHeight: Math.max(330 + (MediaService.players.length > 1 ? 30 : 0), root.showEqualizer ? equalizer.implicitHeight : 0)
RowLayout {
anchors.fill: parent
anchors.margins: 18
spacing: 18
ClippingRectangle {
Layout.alignment: Qt.AlignTop
Layout.preferredWidth: 150
Layout.preferredHeight: 150
radius: 20
color: Theme.fill
Text {
anchors.centerIn: parent
visible: art.status !== Image.Ready
text: Icons.available ? "󰝚" : "♪"
font.family: Icons.available ? Icons.family : ""
font.pixelSize: 52
color: Theme.textSecondary
}
Image {
id: art
anchors.fill: parent
source: MediaService.artwork
sourceSize: Qt.size(300, 300)
fillMode: Image.PreserveAspectCrop
asynchronous: true
opacity: status === Image.Ready ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: Theme.duration
}
}
}
}
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 4
Text {
Layout.fillWidth: true
text: MediaService.title
color: Theme.text
font.pixelSize: 18
font.weight: Font.DemiBold
elide: Text.ElideRight
maximumLineCount: 2
wrapMode: Text.Wrap
}
Text {
Layout.fillWidth: true
text: MediaService.artist
color: Theme.textSecondary
font.pixelSize: 13
elide: Text.ElideRight
}
Text {
Layout.fillWidth: true
visible: text !== ""
text: MediaService.album
color: Theme.textSecondary
opacity: 0.75
font.pixelSize: 12
elide: Text.ElideRight
}
// Cava bars for system audio while playing. The fixed-size
// wrapper keeps bar heights out of the layout: otherwise each
// Cava frame re-polished the column and rendered twice.
Item {
Layout.fillWidth: true
Layout.topMargin: 8
Layout.preferredHeight: 34
Row {
anchors.fill: parent
spacing: 3
opacity: MediaService.playing ? 1 : 0.25
Behavior on opacity {
NumberAnimation {
duration: Theme.duration
}
}
Repeater {
model: 24
Rectangle {
required property int index
anchors.bottom: parent.bottom
width: 4
radius: 2
height: Math.max(3, 34 * (MediaService.playing ? (CavaService.bars[index] || 0) : 0.05))
color: Qt.alpha(Theme.accentVivid, 0.85)
// No height Behavior: Cava already smooths at 30 fps, and
// interpolating raised rendering to the display rate.
}
}
}
}
Item {
Layout.fillHeight: true
}
}
}
ColumnLayout {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 18
spacing: 6
GlassSlider {
objectName: "dashSeek"
Layout.fillWidth: true
from: 0
to: root.live ? 1 : Math.max(1, MediaService.length)
value: root.live ? 0 : MediaService.position
enabled: MediaService.seekable && !root.live
opacity: root.live ? 0.4 : 1
onMoved: MediaService.seek(value)
}
RowLayout {
Layout.fillWidth: true
Layout.topMargin: -6
Text {
text: MediaService.time(MediaService.position)
color: Theme.textSecondary
font.pixelSize: 11
font.features: {
"tnum": 1
}
}
Item {
Layout.fillWidth: true
}
Text {
text: root.live ? "LIVE" : MediaService.time(MediaService.length)
color: Theme.textSecondary
font.pixelSize: 11
font.features: {
"tnum": 1
}
}
}
Row {
Layout.alignment: Qt.AlignHCenter
spacing: 12
DashButton {
objectName: "dashShuffle"
anchors.verticalCenter: parent.verticalCenter
glyph: "󰒝"
fallback: "⤨"
size: 34
active: !!root.player && root.player.shuffle
interactive: !!root.player && root.player.shuffleSupported && root.player.canControl
onClicked: root.player.shuffle = !root.player.shuffle
Accessible.name: "Shuffle"
}
DashButton {
anchors.verticalCenter: parent.verticalCenter
glyph: "󰒮"
fallback: "‹"
size: 40
interactive: !!root.player && root.player.canGoPrevious
onClicked: MediaService.previous()
Accessible.name: "Previous track"
}
DashButton {
objectName: "dashToggle"
size: 54
accented: true
glyph: MediaService.playing ? "󰏤" : "󰐊"
fallback: MediaService.playing ? "Ⅱ" : "▶"
interactive: !!root.player && root.player.canTogglePlaying
onClicked: MediaService.toggle()
Accessible.name: "Play or pause"
}
DashButton {
anchors.verticalCenter: parent.verticalCenter
glyph: "󰒭"
fallback: "›"
size: 40
interactive: !!root.player && root.player.canGoNext
onClicked: MediaService.next()
Accessible.name: "Next track"
}
DashButton {
objectName: "dashLoop"
anchors.verticalCenter: parent.verticalCenter
glyph: !!root.player && root.player.loopState === MprisLoopState.Track ? "󰑘" : "󰑖"
fallback: "↻"
size: 34
active: !!root.player && root.player.loopState !== MprisLoopState.None
interactive: !!root.player && root.player.loopSupported && root.player.canControl
onClicked: root.player.loopState = root.player.loopState === MprisLoopState.None ? MprisLoopState.Playlist : root.player.loopState === MprisLoopState.Playlist ? MprisLoopState.Track : MprisLoopState.None
Accessible.name: "Repeat"
}
}
// Player chooser when several MPRIS players are present.
Flow {
Layout.fillWidth: true
Layout.topMargin: 4
spacing: 6
visible: MediaService.players.length > 1
Repeater {
model: MediaService.players
Rectangle {
id: chip
required property var modelData
readonly property bool active: MediaService.player === modelData
implicitWidth: chipText.implicitWidth + 20
implicitHeight: 24
radius: 12
color: active ? Qt.alpha(Theme.accent, 0.3) : chipArea.containsMouse ? Theme.hover : Theme.fill
border.width: 1
border.color: active ? Qt.alpha(Theme.accent, 0.6) : Theme.hairline
Text {
id: chipText
anchors.centerIn: parent
text: chip.modelData.identity || chip.modelData.dbusName
color: Theme.text
font.pixelSize: 11
}
MouseArea {
id: chipArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: MediaService.choose(chip.modelData.dbusName)
}
}
}
}
}
}
Equalizer {
id: equalizer
visible: root.showEqualizer
Layout.alignment: Qt.AlignTop
Layout.preferredHeight: Math.max(implicitHeight, playerCard.Layout.preferredHeight)
}
}
}