Files
glassMxrph/quickshell/notch/NotchMedia.qml
T
mxandClaude Opus 5.5 efaace0f15 Add notch speeds and a glassy-when-open option
- Settings → Notch → Look: separate opening, closing and colour-change
  speeds for the notch and the notch-mode launcher.
- "Glassy when open" keeps the custom colour/opacity on the docked notch
  and fades the open notch and launcher back to the normal glass; closing
  never outlasts the shrink, so it docks in the docked colour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 17:24:31 +01:00

178 lines
6.3 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import Quickshell.Widgets
import "../components"
import "../dashboard"
import "../services"
import "../theme"
// The notch's Media page: large artwork, track, seek bar, transport and a
// Cava strip, sized to fill the left column.
Item {
id: root
property bool active: false
// Streams report no length or absurd ones; show them as live.
readonly property bool live: MediaService.length <= 0 || MediaService.length > 7 * 86400
readonly property bool hasPlayer: !!MediaService.player
readonly property real artSize: Math.max(120, Math.min(width - 40, height - 250, 250))
Demand {
service: MediaService
counter: "progressConsumers"
active: root.active
}
Demand {
service: CavaService
counter: "widgetConsumers"
active: root.active
}
Column {
anchors.centerIn: parent
width: parent.width - 24
spacing: 14
ClippingRectangle {
anchors.horizontalCenter: parent.horizontalCenter
width: root.artSize
height: root.artSize
radius: 24
color: Theme.fill
border.width: 1
border.color: Theme.hairline
Text {
anchors.centerIn: parent
visible: art.status !== Image.Ready
text: Icons.available ? "󰝚" : "♪"
font.family: Icons.available ? Icons.family : ""
font.pixelSize: root.artSize * 0.32
color: Theme.textSecondary
}
Image {
id: art
anchors.fill: parent
source: MediaService.artwork
sourceSize: Qt.size(500, 500)
fillMode: Image.PreserveAspectCrop
asynchronous: true
retainWhileLoading: true
opacity: status === Image.Ready ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: Theme.notchDuration
}
}
}
}
Column {
width: parent.width
spacing: 3
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: MediaService.title
color: Theme.text
font.pixelSize: 18
font.weight: Font.DemiBold
elide: Text.ElideRight
}
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: MediaService.artist
color: Theme.textSecondary
font.pixelSize: 13
elide: Text.ElideRight
}
}
Column {
visible: root.hasPlayer
width: parent.width
GlassSlider {
objectName: "notchSeek"
width: parent.width
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)
}
Item {
width: parent.width
height: 14
Text {
text: root.live ? "" : MediaService.time(MediaService.position)
color: Theme.textSecondary
font.pixelSize: 11
font.features: {
"tnum": 1
}
}
Text {
anchors.right: parent.right
text: root.live ? "LIVE" : MediaService.time(MediaService.length)
color: Theme.textSecondary
font.pixelSize: 11
font.features: {
"tnum": 1
}
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 22
DashButton {
anchors.verticalCenter: parent.verticalCenter
objectName: "notchPrevious"
size: 44
glyph: "󰒮"
fallback: "⏮"
interactive: root.hasPlayer && MediaService.player.canControl && MediaService.player.canGoPrevious
onClicked: MediaService.previous()
Accessible.name: "Previous track"
}
DashButton {
anchors.verticalCenter: parent.verticalCenter
objectName: "notchToggle"
size: 60
accented: true
glyph: MediaService.playing ? "󰏤" : "󰐊"
fallback: MediaService.playing ? "⏸" : "▶"
interactive: root.hasPlayer && MediaService.player.canControl && MediaService.player.canTogglePlaying
onClicked: MediaService.toggle()
Accessible.name: MediaService.playing ? "Pause" : "Play"
}
DashButton {
anchors.verticalCenter: parent.verticalCenter
objectName: "notchNext"
size: 44
glyph: "󰒭"
fallback: "⏭"
interactive: root.hasPlayer && MediaService.player.canControl && MediaService.player.canGoNext
onClicked: MediaService.next()
Accessible.name: "Next track"
}
}
// Fixed-height wrapper keeps Cava frames from re-laying out the column.
Item {
width: parent.width
height: 30
Row {
anchors.fill: parent
spacing: 3
opacity: MediaService.playing ? 1 : 0.25
Repeater {
model: 24
Rectangle {
required property int index
anchors.bottom: parent.bottom
width: (root.width - 24 - 23 * 3) / 24
radius: 2
height: Math.max(3, 30 * (MediaService.playing ? (CavaService.bars[index] || 0) : 0.05))
color: Qt.alpha(Theme.accentVivid, 0.85)
}
}
}
}
}
}