Modules are tiles on a 4-column grid, each 1x1 to 4x4 and adapting its layout to its size. Edit Controls in the panel reorders by dragging, resizes from a corner handle, removes with a badge and adds from a tray. Connectivity splits into Wi-Fi, Bluetooth and Network tiles and Audio into Sound and Microphone; right-clicking Sound extends it with output devices and a volume slider per app. Adds a Caffeine tile. Config version 2 migrates existing layouts in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
269 lines
8.3 KiB
QML
269 lines
8.3 KiB
QML
pragma ComponentBehavior: Bound
|
||
import QtQuick
|
||
import QtQuick.Layouts
|
||
import Quickshell.Widgets
|
||
import ".."
|
||
import "../../components"
|
||
import "../../services"
|
||
import "../../theme"
|
||
|
||
// Now Playing tile. 1×1 is a round play button over the artwork; one row puts
|
||
// the artwork beside the track; taller tiles stack artwork, track and controls,
|
||
// with a progress bar from three rows.
|
||
CCModule {
|
||
id: root
|
||
readonly property bool canControl: !!MediaService.player && MediaService.player.canControl
|
||
readonly property bool showProgress: rows >= 3 && wide && MediaService.length > 0
|
||
objectName: "nowPlayingTile"
|
||
round: true
|
||
hovered: area.containsMouse
|
||
Demand {
|
||
service: MediaService
|
||
counter: "progressConsumers"
|
||
active: root.showProgress
|
||
}
|
||
|
||
component Art: ClippingRectangle {
|
||
id: artFrame
|
||
property real size: 48
|
||
implicitWidth: size
|
||
implicitHeight: size
|
||
radius: Math.max(8, size * 0.18)
|
||
color: Theme.surfaceVariant
|
||
Text {
|
||
anchors.centerIn: parent
|
||
visible: art.status !== Image.Ready
|
||
text: Icons.available ? "" : "♫"
|
||
font.family: Icons.available ? Icons.family : ""
|
||
font.pixelSize: Math.round(artFrame.size * 0.4)
|
||
color: Theme.textSecondary
|
||
}
|
||
Image {
|
||
id: art
|
||
anchors.fill: parent
|
||
source: MediaService.artwork
|
||
sourceSize: Qt.size(192, 192)
|
||
asynchronous: true
|
||
retainWhileLoading: true
|
||
fillMode: Image.PreserveAspectCrop
|
||
}
|
||
}
|
||
component Track: ColumnLayout {
|
||
property int titleSize: 13
|
||
property int align: Text.AlignLeft
|
||
spacing: 1
|
||
Text {
|
||
text: MediaService.title
|
||
color: Theme.text
|
||
font.pixelSize: parent.titleSize
|
||
font.weight: Font.DemiBold
|
||
elide: Text.ElideRight
|
||
horizontalAlignment: parent.align
|
||
Layout.fillWidth: true
|
||
}
|
||
Text {
|
||
text: MediaService.artist
|
||
visible: text !== ""
|
||
color: Theme.textSecondary
|
||
font.pixelSize: 11
|
||
elide: Text.ElideRight
|
||
horizontalAlignment: parent.align
|
||
Layout.fillWidth: true
|
||
}
|
||
}
|
||
component Control: Item {
|
||
id: control
|
||
property string glyph
|
||
property string fallback
|
||
property bool main: false
|
||
property bool available: true
|
||
signal clicked
|
||
implicitWidth: main ? 34 : 28
|
||
implicitHeight: implicitWidth
|
||
enabled: root.canControl && available
|
||
opacity: enabled ? 1 : 0.4
|
||
Accessible.role: Accessible.Button
|
||
Rectangle {
|
||
anchors.fill: parent
|
||
radius: width / 2
|
||
color: control.main ? Qt.alpha(Theme.text, controlArea.containsMouse ? 0.2 : 0.12) : controlArea.containsMouse ? Theme.hover : Theme.transparent
|
||
}
|
||
Text {
|
||
anchors.centerIn: parent
|
||
text: Icons.available ? control.glyph : control.fallback
|
||
font.family: Icons.available ? Icons.family : ""
|
||
font.pixelSize: control.main ? 17 : 15
|
||
color: Theme.text
|
||
scale: controlArea.pressed ? 0.9 : 1
|
||
}
|
||
MouseArea {
|
||
id: controlArea
|
||
anchors.fill: parent
|
||
hoverEnabled: true
|
||
cursorShape: Qt.PointingHandCursor
|
||
onClicked: control.clicked()
|
||
}
|
||
}
|
||
component Controls: RowLayout {
|
||
property bool full: true
|
||
spacing: 4
|
||
Control {
|
||
visible: parent.full
|
||
glyph: ""
|
||
fallback: "⏮"
|
||
available: !!MediaService.player && MediaService.player.canGoPrevious
|
||
onClicked: MediaService.previous()
|
||
Accessible.name: "Previous track"
|
||
}
|
||
Control {
|
||
objectName: "ccMediaToggle"
|
||
main: true
|
||
glyph: MediaService.playing ? "" : ""
|
||
fallback: MediaService.playing ? "Ⅱ" : "▶"
|
||
available: !!MediaService.player && MediaService.player.canTogglePlaying
|
||
onClicked: MediaService.toggle()
|
||
Accessible.name: MediaService.playing ? "Pause" : "Play"
|
||
}
|
||
Control {
|
||
visible: parent.full
|
||
glyph: ""
|
||
fallback: "⏭"
|
||
available: !!MediaService.player && MediaService.player.canGoNext
|
||
onClicked: MediaService.next()
|
||
Accessible.name: "Next track"
|
||
}
|
||
}
|
||
|
||
MouseArea {
|
||
id: area
|
||
anchors.fill: parent
|
||
hoverEnabled: true
|
||
onClicked: if (root.compact && root.canControl)
|
||
MediaService.toggle()
|
||
}
|
||
GlassToolTip {
|
||
visible: root.compact && area.containsMouse
|
||
delay: 500
|
||
text: MediaService.title + (MediaService.artist ? " · " + MediaService.artist : "")
|
||
}
|
||
|
||
// 1×1: artwork filling the circle with the play state on top.
|
||
ClippingRectangle {
|
||
visible: root.compact
|
||
x: root.background.x
|
||
y: root.background.y
|
||
width: root.background.width
|
||
height: root.background.height
|
||
radius: width / 2
|
||
color: Theme.transparent
|
||
Image {
|
||
anchors.fill: parent
|
||
source: root.compact ? MediaService.artwork : ""
|
||
sourceSize: Qt.size(128, 128)
|
||
asynchronous: true
|
||
fillMode: Image.PreserveAspectCrop
|
||
opacity: 0.55
|
||
}
|
||
Text {
|
||
anchors.centerIn: parent
|
||
text: Icons.available ? (MediaService.playing ? "" : "") : (MediaService.playing ? "Ⅱ" : "▶")
|
||
font.family: Icons.available ? Icons.family : ""
|
||
font.pixelSize: Math.round(root.background.width * 0.32)
|
||
color: Theme.text
|
||
}
|
||
}
|
||
|
||
// One row: artwork, track, controls.
|
||
RowLayout {
|
||
visible: root.wide && !root.tall
|
||
anchors.fill: parent
|
||
anchors.margins: 10
|
||
anchors.rightMargin: 12
|
||
spacing: 10
|
||
Art {
|
||
size: root.baseHeight - 20
|
||
}
|
||
Track {
|
||
Layout.fillWidth: true
|
||
}
|
||
Controls {
|
||
full: root.cols >= 3
|
||
}
|
||
}
|
||
|
||
// One column: artwork above the play button.
|
||
ColumnLayout {
|
||
visible: !root.wide && root.tall
|
||
anchors.fill: parent
|
||
anchors.margins: 10
|
||
spacing: 8
|
||
Art {
|
||
size: Math.min(root.width - 20, root.baseHeight - 64)
|
||
Layout.alignment: Qt.AlignHCenter
|
||
}
|
||
Track {
|
||
visible: root.rows >= 3
|
||
titleSize: 11
|
||
align: Text.AlignHCenter
|
||
Layout.fillWidth: true
|
||
}
|
||
Item {
|
||
Layout.fillHeight: true
|
||
}
|
||
Controls {
|
||
full: false
|
||
Layout.alignment: Qt.AlignHCenter
|
||
}
|
||
}
|
||
|
||
// Large: artwork and track on top, controls along the bottom.
|
||
ColumnLayout {
|
||
visible: root.wide && root.tall
|
||
anchors.fill: parent
|
||
anchors.margins: 14
|
||
spacing: 8
|
||
RowLayout {
|
||
Layout.fillWidth: true
|
||
spacing: 12
|
||
Art {
|
||
size: Math.min(root.rows >= 3 ? 96 : 56, root.width / 2 - 14)
|
||
}
|
||
Track {
|
||
titleSize: root.cols >= 3 ? 15 : 13
|
||
Layout.fillWidth: true
|
||
Layout.alignment: Qt.AlignVCenter
|
||
}
|
||
}
|
||
Item {
|
||
Layout.fillHeight: true
|
||
}
|
||
RowLayout {
|
||
visible: root.showProgress
|
||
Layout.fillWidth: true
|
||
spacing: 6
|
||
Text {
|
||
text: MediaService.time(MediaService.position)
|
||
color: Theme.textSecondary
|
||
font.pixelSize: 10
|
||
}
|
||
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: 10
|
||
}
|
||
}
|
||
Controls {
|
||
Layout.alignment: Qt.AlignHCenter
|
||
}
|
||
}
|
||
}
|