Skip to content

armgit / Spun

Public Imported from GitHub
0

A CD-shaped music player for Linux, with local playback and Cider integration.

Add physical player bodies and refine media realism

yappologisticf3a6e5ee8997
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d21afa..d804a66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,7 +42,7 @@ qt_add_library(spun_core STATIC
src/listening.cpp src/listening.h src/tapesound.cpp src/tapesound.h src/vinylnoise.cpp src/vinylnoise.h
src/musicactions.cpp src/musicactions.h
src/library.cpp src/library.h src/lyrics.cpp src/lyrics.h src/artwork.cpp src/artwork.h
- src/player.cpp src/player.h src/disc.cpp src/disc.h src/mpris.cpp src/mpris.h
+ src/player.cpp src/player.h src/disc.cpp src/disc.h src/playerbody.cpp src/playerbody.h src/mpris.cpp src/mpris.h
src/theme.cpp src/theme.h src/cider.cpp src/cider.h src/ciderevents.cpp src/ciderevents.h)
target_link_libraries(spun_core PUBLIC Qt6::Core Qt6::Gui Qt6::Quick Qt6::Qml Qt6::QuickControls2
Qt6::Svg Qt6::Multimedia Qt6::Concurrent Qt6::DBus Qt6::Network PkgConfig::TAGLIB)
diff --git a/README.md b/README.md
index 9f79bd8..456ae0c 100644
--- a/README.md
+++ b/README.md
@@ -108,6 +108,8 @@ Spun connects to Cider's local API on port 10767. Basic playback controls use Li
- **Queue browsing:** scrolling away keeps your place when playback advances. **Current song** returns to the playing track and resumes following it.
- **Disc reverse:** double-click the disc or press **F** to see album details and tracks. Switch to lyrics with **Y** when available. Local lyrics can come from matching `.lrc` / `.txt` files or embedded metadata.
- **Disc appearance:** choose **CD**, **Vinyl** or **Cassette** in **More → Preferences**. Vinyl keeps the artwork on its center label, with grooves, a small spindle hole, and a gold tonearm. The arm lowers for playback, tracks inward through the song, and parks on pause. It scales with Mini mode, stays out of the reverse view and disc swaps, and respects reduced motion. Cassette mode adds a tape shell, reels that turn counterclockwise during forward playback and reverse while rewinding, a horizontal progress bar and optional transport sounds. All three styles share playback, reverse-side details, lyrics and Mini mode. Your choice is remembered.
+- **Player bodies:** **Show player body** in Preferences adds a turntable, a portable cassette player or a CD tray with a clear lid. Mini mode keeps the compact medium. Cassette finishes include Clear, Smoke and Cream. Album changes briefly show a sleeve or case and move the lid and medium; playback starts immediately. Changing tracks within an album keeps the same medium. Reduced motion skips the loading sequence. The reverse uses a matching case or booklet for the existing album details and lyrics.
+- **CD speed:** enable **500 RPM** in CD Preferences for faster visual rotation. Audio speed stays unchanged; reduced motion still applies.
- **Vinyl controls:** choose 33⅓ or 45 RPM, enable a horizontal progress bar, or add optional crackle, hiss and groove skips in Preferences. Drag the needle onto the grooves to seek and play.
- **Albums as records:** enable **Play albums as records** in Vinyl preferences to give each album track its own groove band. Drop the needle to choose a song and position. Local mode uses the album tracks already loaded into Spun, in track-number order. With Cider, a drop starts the album in its queue, then verifies the track before seeking. Missing durations or unavailable tracks keep ordinary single-song seeking. The horizontal bar always seeks within the current song.
- **Desktop controls:** Spun’s desktop media entry follows the selected Local or Cider source, including artwork, playback state, volume and seeking. Cider may also expose its own desktop entry.
diff --git a/qml/Main.qml b/qml/Main.qml
index 08ccda0..48dd695 100644
--- a/qml/Main.qml
+++ b/qml/Main.qml
@@ -22,6 +22,12 @@ ApplicationWindow {
color: "transparent"
flags: Qt.Window | Qt.FramelessWindowHint | (miniPinned && !native.supportsBlur ? Qt.WindowStaysOnTopHint : 0)
font.family: SpunStyle.family
+ readonly property bool bodyVisible: player.showPlayerBody && !miniMode
+ readonly property real mediumScale: bodyVisible && !discFlipped ? .86 : 1
+ readonly property color cassetteShell: player.cassetteFinish === "cream" ? "#bab29c" : player.cassetteFinish === "clear" ? "#b06f8285" : root.surface
+ property real lidOpen: 0
+ property real packageOpacity: 0
+ onBodyVisibleChanged: Qt.callLater(function() { stopSwap(); cancelSeekPreview(); updateMask() })
readonly property bool cassette: player.medium === "cassette"
onCassetteChanged: Qt.callLater(function() { stopSwap(); scrubber.cancelScrub(); updateMask() })
readonly property bool vinyl: player.vinyl
@@ -37,7 +43,7 @@ ApplicationWindow {
if (crossfadeMenu.visible) { crossfadeMenu.service.refreshCrossfade(); crossfadeMenu.service.refreshAudioOptions() }
if (qualityPopup.visible) root.ciderService.refreshAudioQuality()
}
- Connections { target: player; function onSettingsChanged() { if (!player.vinylAlbumMode || !player.vinyl) root.listeningService.cancelAlbumPosition() } }
+ Connections { target: player; function onMediumChanged() { root.spinSpeed = 0; root.stopSwap(); Qt.callLater(root.updateMask) } function onSettingsChanged() { if (!player.vinylAlbumMode || !player.vinyl) root.listeningService.cancelAlbumPosition() } }
Connections { target: root.listeningService; function onFeedback(message, error) { root.notifyAction(message, error) } }
Connections { target: root.ciderService; function onRemoteSettingsChanged() { root.refreshOpenCiderDetails() } }
Timer {
@@ -77,7 +83,8 @@ ApplicationWindow {
property real incomingOpacity: 1
property real outgoingAngle: 0
readonly property bool swapRunning: animate && discSwap.running
- function resetSwap() { swapOffset = 0; outgoingOffset = 0; outgoingOpacity = 0; incomingOpacity = 1 }
+ onSwapRunningChanged: Qt.callLater(updateMask)
+ function resetSwap() { swapOffset = 0; outgoingOffset = 0; outgoingOpacity = 0; incomingOpacity = 1; lidOpen = 0; packageOpacity = 0 }
function stopSwap() { discSwap.stop(); resetSwap(); presentation.releaseOutgoing() }
function presentDisc() {
const albumKey = deckPlayer.count ? (useCider ? "cider:" : "local:") + (deckPlayer.albumKey || deckPlayer.title) : ""
@@ -346,6 +353,7 @@ ApplicationWindow {
property real cassetteRightAngle: 0
property real outgoingCassetteLeftAngle: 0
property real outgoingCassetteRightAngle: 0
+ readonly property real cdDegreesPerSecond: player.cd500Rpm ? 3000 : 9
readonly property real vinylDegreesPerSecond: player.vinylSpeed === 45 ? 270 : player.vinylSpeed === 33 ? 200 : 9
readonly property bool showHorizontalSeek: player.horizontalSeek && !cassette && deckPlayer.count > 0
onShowHorizontalSeekChanged: Qt.callLater(updateMask)
@@ -462,7 +470,7 @@ ApplicationWindow {
const now = Date.now()
const dt = Math.min(.05, (now-lastTime)/1000)
lastTime = now
- const target = root.deckPlayer.playing ? (root.vinyl ? root.vinylDegreesPerSecond : 9) : 0
+ const target = root.deckPlayer.playing ? (root.vinyl ? root.vinylDegreesPerSecond : root.cassette ? 9 : root.cdDegreesPerSecond) : 0
root.spinSpeed += (target-root.spinSpeed)*Math.min(1,dt*2.2)
if (!root.discFlipped) root.spinAngle = (root.spinAngle+root.spinSpeed*dt)%360
const winding = root.cassette && root.activeSeekControl
@@ -566,11 +574,29 @@ ApplicationWindow {
IconButton { visible: !native.hyprland; x: 300; y: 4; glyphName: "close"; tip: "Close Spun"; ink: root.mutedInk; hoverFill: root.hoverFill; onClicked: Qt.quit() }
}
+ PlayerBody {
+ objectName: "playerBody"
+ x: 45; y: 74; width: 440; height: 440
+ visible: root.bodyVisible && !root.discFlipped
+ medium: player.medium; surface: root.surface
+ }
+ PlayerBody {
+ objectName: "albumPackage"
+ x: 45; y: 74; width: 440; height: 440
+ visible: root.bodyVisible && root.packageOpacity > 0
+ opacity: root.packageOpacity
+ medium: player.medium; surface: root.surface; artwork: presentation.artwork; part: 2
+ scale: .9 + .1 * root.packageOpacity
+ transform: Rotation { origin.x: 44; origin.y: 220; axis.x: 0; axis.y: 1; axis.z: 0; angle: root.vinyl ? 0 : -35*root.lidOpen }
+ }
Item {
id: platter
- x: root.miniMode ? 9.2 : 45; y: root.miniMode ? 9.2 : 74
+ x: root.miniMode ? 9.2 : 45 + 220*(1-root.mediumScale); y: root.miniMode ? 9.2 : 74 + 220*(1-root.mediumScale)
width: 440; height: 440; clip: true
- scale: root.miniMode ? .64 : 1
+ scale: root.miniMode ? .64 : root.mediumScale
+ Behavior on scale { enabled: root.bodyVisible && root.animate; NumberAnimation { duration: SpunStyle.feedback; easing.type: Easing.BezierSpline; easing.bezierCurve: SpunStyle.standardCurve } }
+ Behavior on x { enabled: root.bodyVisible && root.animate; NumberAnimation { duration: SpunStyle.feedback; easing.type: Easing.BezierSpline; easing.bezierCurve: SpunStyle.standardCurve } }
+ Behavior on y { enabled: root.bodyVisible && root.animate; NumberAnimation { duration: SpunStyle.feedback; easing.type: Easing.BezierSpline; easing.bezierCurve: SpunStyle.standardCurve } }
transformOrigin: Item.TopLeft
HoverHandler {
id: platterHover
@@ -601,8 +627,8 @@ ApplicationWindow {
opacity: root.outgoingOpacity
transform: Translate { x: root.outgoingOffset }
sourceComponent: Item {
- Disc { cassette: root.cassette; shellColor: root.surface; vinyl: root.vinyl; anchors.fill: parent; artwork: presentation.outgoing; rotation: root.cassette ? 0 : root.outgoingAngle }
- Disc { visible: !root.cassette; cassette: root.cassette; shellColor: root.surface; vinyl: root.vinyl; anchors.fill: parent; overlay: true }
+ Disc { cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl; anchors.fill: parent; artwork: presentation.outgoing; rotation: root.cassette ? 0 : root.outgoingAngle }
+ Disc { visible: !root.cassette; cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl; anchors.fill: parent; overlay: true }
Loader { anchors.fill: parent; active: root.cassette; sourceComponent: CassetteReels { app: root; outgoing: true } }
}
}
@@ -624,14 +650,14 @@ ApplicationWindow {
}
front: Item {
anchors.fill: parent
- Disc { cassette: root.cassette; shellColor: root.surface; vinyl: root.vinyl;
+ Disc { cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl;
id: face
objectName: "discFace"
anchors.fill: parent
artwork: presentation.artwork
rotation: root.cassette ? 0 : root.spinAngle
}
- Disc { visible: !root.cassette; cassette: root.cassette; shellColor: root.surface; vinyl: root.vinyl; anchors.fill: parent; overlay: true }
+ Disc { visible: !root.cassette; cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl; anchors.fill: parent; overlay: true }
Loader {
anchors.fill: parent; active: root.recordMap !== null
sourceComponent: Canvas {
@@ -655,7 +681,9 @@ ApplicationWindow {
back: Item {
objectName: "discBack"
anchors.fill: parent
- Disc { cassette: root.cassette; shellColor: root.surface; vinyl: root.vinyl; anchors.fill: parent; labelColor: root.surface }
+ Disc { visible: !root.bodyVisible; cassette: root.cassette; shellColor: root.cassetteShell; vinyl: root.vinyl; anchors.fill: parent; labelColor: root.surface }
+ PlayerBody { objectName: "albumBooklet"; anchors.fill: parent; visible: root.bodyVisible; medium: player.medium; surface: root.surface; part: 3 }
+ ArtworkView { x: 46; y: 60; width: 30; height: 30; visible: root.bodyVisible && !root.cassette; artwork: presentation.artwork }
SpunText {
objectName: "discAlbumTitle"
id: albumHeading
@@ -690,7 +718,7 @@ ApplicationWindow {
ListView {
id: albumList
objectName: "albumTrackList"
- x: root.cassette ? 38 : 68; y: root.cassette ? 176 : 262; width: root.cassette ? 334 : 274; height: root.cassette ? 116 : root.miniMode ? 76 : 82
+ x: root.cassette ? 38 : 68; y: root.cassette ? 176 : root.bodyVisible ? 166 : 262; width: root.cassette ? 334 : 274; height: root.bodyVisible ? (root.cassette ? 162 : 172) : root.cassette ? 116 : root.miniMode ? 76 : 82
readonly property int rowHeight: root.miniMode ? 36 : 32
property int rememberedRow: 0
property string rememberedAlbum: ""
@@ -774,7 +802,7 @@ ApplicationWindow {
ListView {
id: lyricList
objectName: "lyricList"
- x: root.cassette ? 42 : 76; y: root.cassette ? 176 : 260; width: root.cassette ? 326 : 258; height: root.cassette ? 116 : 84
+ x: root.cassette ? 42 : 76; y: root.cassette ? 176 : root.bodyVisible ? 166 : 260; width: root.cassette ? 326 : 258; height: root.bodyVisible ? (root.cassette ? 162 : 172) : root.cassette ? 116 : 84
visible: root.lyricsView && lyrics.lines.length > 0
model: lyrics.lines; clip: true; spacing: 8
boundsBehavior: Flickable.StopAtBounds
@@ -894,7 +922,7 @@ ApplicationWindow {
}
}
Column {
- x: 80; y: root.cassette ? 182 : 262; width: 250; spacing: 4
+ x: 80; y: root.cassette || root.bodyVisible ? 182 : 262; width: 250; spacing: 4
visible: root.lyricsView && !lyrics.lines.length
SpunText {
width: parent.width; text: lyrics.loading ? "Loading lyrics…" : lyrics.message
@@ -912,7 +940,7 @@ ApplicationWindow {
Row {
objectName: "discBackFooter"
anchors.horizontalCenter: parent.horizontalCenter
- y: root.cassette ? 298 : 348; height: 36; spacing: 10
+ y: root.cassette && !root.bodyVisible ? 298 : 348; height: 36; spacing: 10
SpunText {
anchors.verticalCenter: parent.verticalCenter
visible: !root.lyricsView && root.albumTracks.length > 0
@@ -943,7 +971,7 @@ ApplicationWindow {
}
Column {
- x: 80; y: root.cassette ? 182 : 264; width: 250; spacing: 5
+ x: 80; y: root.cassette || root.bodyVisible ? 182 : 264; width: 250; spacing: 5
visible: !root.lyricsView && root.useCider && !root.albumTracks.length
SpunText {
width: parent.width; horizontalAlignment: Text.AlignHCenter; wrapMode: Text.WordWrap
@@ -988,9 +1016,11 @@ ApplicationWindow {
Loader {
id: armLoader
objectName: "tonearmLoader"
+ // The arm and counterweight physically occlude the seek ring.
+ z: 3
anchors.fill: parent
active: root.vinyl
- visible: active && !root.discFlipped && !root.swapRunning
+ visible: active && !root.discFlipped && (!root.swapRunning || root.bodyVisible)
sourceComponent: Tonearm { app: root }
}
Connections {
@@ -1002,6 +1032,7 @@ ApplicationWindow {
if (!root.animate || root.discFlipped || !root.visible || !native.exposed) { presentation.releaseOutgoing(); return }
scrubber.cancelScrub(); root.outgoingAngle = root.spinAngle; root.outgoingCassetteLeftAngle = root.cassetteLeftAngle; root.outgoingCassetteRightAngle = root.cassetteRightAngle
root.swapOffset = 440; root.outgoingOffset = 0; root.outgoingOpacity = 1; root.incomingOpacity = 0
+ root.packageOpacity = root.bodyVisible ? 1 : 0
discSwap.departureTime = SpunStyle.enter; discSwap.arrivalTime = SpunStyle.hero
discSwap.start()
}
@@ -1013,6 +1044,7 @@ ApplicationWindow {
// sequence explicitly instead of rewriting its active durations.
property int departureTime: 200
property int arrivalTime: 350
+ NumberAnimation { target: root; property: "lidOpen"; to: 1; duration: root.bodyVisible ? SpunStyle.exit : 0 }
ParallelAnimation {
NumberAnimation { target: root; property: "outgoingOffset"; to: -440; duration: discSwap.departureTime; easing.type: Easing.BezierSpline; easing.bezierCurve: SpunStyle.exitCurve }
NumberAnimation { target: root; property: "outgoingOpacity"; to: 0; duration: discSwap.departureTime }
@@ -1020,13 +1052,15 @@ ApplicationWindow {
ParallelAnimation {
NumberAnimation { target: root; property: "swapOffset"; to: 0; duration: discSwap.arrivalTime; easing.type: Easing.BezierSpline; easing.bezierCurve: SpunStyle.enterCurve }
NumberAnimation { target: root; property: "incomingOpacity"; to: 1; duration: discSwap.departureTime }
+ NumberAnimation { target: root; property: "packageOpacity"; to: 0; duration: discSwap.arrivalTime }
}
+ NumberAnimation { target: root; property: "lidOpen"; to: 0; duration: root.bodyVisible ? SpunStyle.exit : 0 }
onFinished: { root.resetSwap(); presentation.releaseOutgoing() }
}
ProgressRing {
objectName: "progressRing"
anchors.fill: parent
- visible: !root.cassette && root.deckPlayer.count > 0
+ visible: !root.cassette && !(root.bodyVisible && root.discFlipped) && root.deckPlayer.count > 0
progress: scrubber.scrubbing ? scrubber.previewFraction : root.recordProgress
phase: root.wavePhase
amplitude: root.deckPlayer.playing ? 2.8 : 0
@@ -1046,7 +1080,7 @@ ApplicationWindow {
readonly property bool canSeek: !root.swapRunning && root.deckPlayer.duration > 0 && (!root.useCider || (root.ciderService.canSeek && !root.listeningService.busy))
readonly property bool showPreview: canSeek && (scrubbing || (containsMouse && onRim(mouseX,mouseY)))
cursorShape: canSeek && onRim(mouseX,mouseY) ? Qt.PointingHandCursor : Qt.ArrowCursor
- function onRim(x,y) { let r=Math.hypot(x-220,y-220); return !root.cassette && r > 205 && r < 224 }
+ function onRim(x,y) { let r=Math.hypot(x-220,y-220); return !root.cassette && !(root.bodyVisible && root.discFlipped) && r > 205 && r < 224 }
function updatePreview(x,y) {
let a=Math.atan2(y-220,x-220)+Math.PI/2
if (a < 0) a += 2*Math.PI
@@ -1077,8 +1111,8 @@ ApplicationWindow {
SeekSlider {
app: root
objectName: "cassetteSeek"
- visible: root.cassette && root.deckPlayer.count > 0
- x: 70; y: 365; width: 300; height: 36
+ visible: (root.cassette || (root.bodyVisible && root.discFlipped)) && root.deckPlayer.count > 0
+ x: 70; y: root.bodyVisible && root.discFlipped ? 388 : 365; width: 300; height: 36
}
DropArea {
@@ -1100,6 +1134,14 @@ ApplicationWindow {
}
+ PlayerBody {
+ objectName: "playerLid"
+ x: 45; y: 74; width: 440; height: 440
+ visible: root.bodyVisible && !root.discFlipped
+ medium: player.medium; surface: root.surface; part: 1
+ opacity: 1 - .75*root.lidOpen
+ transform: Scale { origin.x: 220; origin.y: root.cassette ? 112 : 26; yScale: 1 - .35*root.lidOpen }
+ }
Rectangle {
id: rimPreview
objectName: "rimPreview"
@@ -1942,6 +1984,32 @@ ApplicationWindow {
}
}
+ PreferenceSwitch {
+ objectName: "cd500RpmToggle"; app: root; width: parent.width
+ visible: player.medium === "cd"; height: visible ? implicitHeight : 0
+ text: "500 RPM"; glyphName: "disc"; checked: player.cd500Rpm
+ Accessible.description: "Spin the CD at 500 revolutions per minute. Audio playback speed stays unchanged."
+ onToggled: player.cd500Rpm = checked
+ onActiveFocusChanged: if(activeFocus)preferenceScroll.reveal(this)
+ }
+ PreferenceSwitch { objectName: "playerBodyToggle"; app: root; width: parent.width; text: "Show player body"; glyphName: "disc"; checked: player.showPlayerBody; onToggled: player.showPlayerBody = checked; onActiveFocusChanged: if(activeFocus)preferenceScroll.reveal(this) }
+ Row {
+ visible: root.cassette; height: visible ? 40 : 0; spacing: 6; width: parent.width
+ Repeater {
+ model: ["clear", "smoke", "cream"]
+ delegate: SpunButton {
+ required property string modelData
+ objectName: "cassetteFinish_" + modelData
+ width: (parent.width - 12)/3; height: 40
+ text: modelData === "clear" ? "Clear" : modelData === "smoke" ? "Smoke" : "Cream"
+ Accessible.name: text + " cassette finish"
+ Accessible.description: player.cassetteFinish === modelData ? "Selected" : ""
+ tonal: player.cassetteFinish === modelData
+ onClicked: player.cassetteFinish = modelData
+ onActiveFocusChanged: if(activeFocus)preferenceScroll.reveal(this)
+ }
+ }
+ }
AbstractButton {
id: fontChoice
objectName: "fontChoice"
diff --git a/qml/Tonearm.qml b/qml/Tonearm.qml
index 52dc599..8ce2160 100644
--- a/qml/Tonearm.qml
+++ b/qml/Tonearm.qml
@@ -6,7 +6,7 @@ Item {
objectName: "vinylTonearm"
required property var app
readonly property bool motion: app.animate && visible && app.visible && native.exposed
- readonly property bool engaged: visible && app.deckPlayer.count > 0 && (app.deckPlayer.playing || landing)
+ readonly property bool engaged: visible && app.deckPlayer.count > 0 && ((app.deckPlayer.playing && !app.swapRunning) || landing)
readonly property bool canSeek: visible && app.deckPlayer.duration > 0 && (!app.useCider || (app.ciderService.canSeek && !app.listeningService.busy))
property bool dragging: false
property real dragAngle: -4
@@ -84,10 +84,22 @@ Item {
return arm.app.recordMap ? "Drag to choose an album track · Shift for precision" : "Drag to seek · Shift for precision"
}
}
+ Rectangle {
+ x: 377; y: 105; width: 14; height: 35; radius: 5
+ visible: arm.app.bodyVisible
+ color: arm.app.surface; border.width: 1; border.color: arm.shade
+ rotation: -4
+ }
// The pivot rests at the record's edge; the stylus stays outside the label.
Item {
x: 378; y: 100
- Rectangle { x: -15; y: -13; width: 30; height: 30; radius: 15; color: "#50000000" }
+ Rectangle { x: -21; y: -17; width: 42; height: 42; radius: 21; color: "#80000000" }
+ Rectangle {
+ x: -19; y: -19; width: 38; height: 38; radius: 19
+ gradient: Gradient { GradientStop { position: 0; color: "#a0a5a5" } GradientStop { position: .12; color: "#555c5e" } GradientStop { position: .6; color: "#252a2e" } GradientStop { position: 1; color: "#101619" } }
+ border.width: .8; border.color: "#747b7b"
+ Rectangle { anchors.centerIn: parent; width: 31; height: 31; radius: 15.5; color: "#252b2d"; border.width: 1; border.color: "#121718" }
+ }
Rectangle {
x: -13; y: -13; width: 26; height: 26; radius: 13
color: arm.app.surface; border.width: 1; border.color: arm.shade
@@ -97,6 +109,26 @@ Item {
objectName: "tonearmShaft"
rotation: arm.armAngle
transformOrigin: Item.TopLeft
+ Rectangle { visible: arm.app.bodyVisible; x: -3; y: -47; width: 6; height: 39; radius: 2; color: arm.shade }
+ Rectangle {
+ objectName: "tonearmCounterweight"
+ visible: arm.app.bodyVisible
+ x: -15; y: -45; width: 30; height: 27; radius: 5
+ gradient: Gradient {
+ orientation: Gradient.Horizontal
+ GradientStop { position: 0; color: "#242b2e" }
+ GradientStop { position: .16; color: "#737b7d" }
+ GradientStop { position: .34; color: "#c0c6c6" }
+ GradientStop { position: .65; color: "#6e7678" }
+ GradientStop { position: 1; color: "#1c2326" }
+ }
+ border.width: .7; border.color: "#7a8486"
+ Repeater {
+ model: 7
+ Rectangle { required property int index; x: 2; y: 3+index*3; width: 26; height: .6; color: "#70000000" }
+ }
+ Rectangle { x: 1; y: 23; width: 28; height: 3; radius: 1; color: "#262d30" }
+ }
// A displaced hard shadow makes the lift legible without a blur pass.
Rectangle { x: 1 + (1 - arm.lowered) * 2; y: 5; width: 7; height: 187; radius: 3.5; color: "#48000000" }
Rectangle { x: (1 - arm.lowered) * 2; y: 188; width: 14; height: 24; radius: 4; color: "#48000000" }
@@ -125,7 +157,14 @@ Item {
border.width: 1; border.color: arm.gold
Rectangle { x: 4; y: 5; width: 6; height: 2; radius: 1; color: arm.gold }
Rectangle { x: 4; y: 10; width: 6; height: 2; radius: 1; color: arm.gold }
- Rectangle { x: 6; y: 23; width: 2; height: 5; radius: 1; color: arm.glint }
+ Rectangle { x: 2; y: 18; width: 10; height: 5; radius: 1; color: "#171b1d" }
+ Rectangle { x: 6; y: 23; width: 1.2; height: 5; radius: .6; color: "#d5dcde" }
+ Rectangle { x: 5.5; y: 27; width: 2; height: 1.5; radius: .5; color: "#d6c5a8" }
+ Rectangle { x: 12; y: 4; width: 9; height: 2; radius: 1; rotation: -20; color: arm.gold }
+ Repeater {
+ model: 2
+ Rectangle { required property int index; x: 2+index*8; y: 2; width: 2; height: 2; radius: 1; color: "#d1d4ca" }
+ }
}
}
diff --git a/src/disc.cpp b/src/disc.cpp
index 54f1bd2..3fcde97 100644
--- a/src/disc.cpp
+++ b/src/disc.cpp
@@ -134,9 +134,11 @@ void Disc::paintVinyl(QPainter *p) {
if (m_overlay) {
// Fixed light over a rotating, cached record texture; no per-frame painting.
QConicalGradient sheen(center,24);
- sheen.setColorAt(0,Qt::transparent); sheen.setColorAt(.12,QColor(190,202,218,18));
+ sheen.setColorAt(0,Qt::transparent); sheen.setColorAt(.07,Qt::transparent);
+ sheen.setColorAt(.12,QColor(203,216,229,37));sheen.setColorAt(.155,QColor(203,216,229,10));
sheen.setColorAt(.22,Qt::transparent); sheen.setColorAt(.5,Qt::transparent);
- sheen.setColorAt(.63,QColor(255,235,205,14)); sheen.setColorAt(.73,Qt::transparent); sheen.setColorAt(1,Qt::transparent);
+ sheen.setColorAt(.61,QColor(244,233,214,28));sheen.setColorAt(.67,QColor(244,233,214,5));
+ sheen.setColorAt(.73,Qt::transparent); sheen.setColorAt(1,Qt::transparent);
p->fillPath(record,sheen); return;
}
QRadialGradient body(center,500);
@@ -145,10 +147,13 @@ void Disc::paintVinyl(QPainter *p) {
p->fillPath(record,body);
p->setBrush(Qt::NoBrush);
const int inner=m_labelColor.isValid()?475:213;
- for (int r=inner;r<488;r+=4) {
- p->setPen(QPen(QColor(180,185,195,(r%12==1)?26:12),.85));p->drawEllipse(center,r,r);
- p->setPen(QPen(QColor(0,0,0,75),1));p->drawEllipse(center,r+1.5,r+1.5);
+ QRandomGenerator grooveSpacing(44);
+ for (double r=inner;r<488;r+=2.6+grooveSpacing.generateDouble()*1.8) {
+ p->setPen(QPen(QColor(180,185,195,12+grooveSpacing.bounded(16)),.65));p->drawEllipse(center,r,r);
+ p->setPen(QPen(QColor(0,0,0,90),.9));p->drawEllipse(center,r+1.1,r+1.1);
}
+ p->setPen(QPen(QColor(1,2,3,180),3));p->drawEllipse(center,492,492);
+ p->setPen(QPen(QColor(150,163,174,55),.8));p->drawEllipse(center,495,495);
if(!m_labelColor.isValid()) {
for(int r:{242,310,381,452}) { p->setPen(QPen(QColor(2,3,5,115),3));p->drawEllipse(center,r,r); }
}
@@ -163,7 +168,12 @@ void Disc::paintVinyl(QPainter *p) {
}
p->restore();
p->setBrush(Qt::NoBrush);p->setPen(QPen(QColor(0,0,0,120),3));p->drawEllipse(center,radius+1,radius+1);
- if(!m_labelColor.isValid()) {p->setPen(QPen(QColor(255,255,255,32),1));p->drawEllipse(center,178,178);}
+ if(!m_labelColor.isValid()) {
+ // Pressed paper has a shallow concentric label ridge around the spindle.
+ p->setPen(QPen(QColor(0,0,0,85),1.8));p->drawEllipse(center,72,72);
+ p->setPen(QPen(QColor(255,255,255,28),.9));p->drawEllipse(center,74,74);
+ p->setPen(QPen(QColor(255,255,255,32),1));p->drawEllipse(center,178,178);
+ }
p->setPen(QPen(QColor(0,0,0,170),3));p->drawEllipse(center,18,18);
p->setPen(QPen(QColor(255,255,255,40),1));p->drawEllipse(center,21,21);
}
diff --git a/src/main.cpp b/src/main.cpp
index 36e0d39..d3dd9f2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -12,6 +12,7 @@
#include "lyrics.h"
#include "artwork.h"
#include "disc.h"
+#include "playerbody.h"
#include "symbol.h"
#include "mpris.h"
#include "theme.h"
@@ -160,9 +161,19 @@ public:
QPainterPath backdrop; backdrop.addRoundedRect(QRectF(0, 0, targetWidth, targetHeight), 21, 21);
setMask(QRegion(backdrop.toFillPolygon().toPolygon())); return;
}
+ const bool body=window->property("bodyVisible").toBool();
QRegion region=cassette?QRegion(60,156,410,276):QRegion(44,73,442,442,QRegion::Ellipse);
if(cassette)region|=QRegion(115,439,300,36);
- if(!cassette)region -= window->property("vinyl").toBool()?QRegion(259,288,12,12,QRegion::Ellipse):QRegion(243,272,44,44,QRegion::Ellipse);
+ if(body) {
+ QPainterPath housing;
+ if(window->property("discFlipped").toBool())housing.addRoundedRect(QRectF(87,104,357,387),5,5);
+ else if(cassette)housing.addRoundedRect(QRectF(58,151,414,295),28,28);
+ else housing.addRoundedRect(QRectF(45,74,440,440),window->property("vinyl").toBool()?28:220,window->property("vinyl").toBool()?28:220);
+ region=QRegion(housing.toFillPolygon().toPolygon());
+ if(cassette)if(auto *seek=window->findChild<QQuickItem *>("cassetteSeek"))region|=itemRegion(seek);
+ if(window->property("swapRunning").toBool())region|=QRegion(45,74,440,440);
+ }
+ if(!cassette && !body)region -= window->property("vinyl").toBool()?QRegion(259,288,12,12,QRegion::Ellipse):QRegion(243,272,44,44,QRegion::Ellipse);
if (auto *bar = window->findChild<QQuickItem *>("sourceBar"))
region |= itemRegion(bar);
if (auto *deck = window->findChild<QQuickItem *>("playerDeck"))
@@ -1577,6 +1588,7 @@ int main(int argc, char **argv) {
const qint64 backendReady = startup.elapsed();
qmlRegisterType<Symbol>("Spun", 1, 0, "Symbol");
+ qmlRegisterType<PlayerBody>("Spun",1,0,"PlayerBody");
qmlRegisterType<Disc>("Spun", 1, 0, "Disc");
qmlRegisterType<ArtworkView>("Spun", 1, 0, "ArtworkView");
qmlRegisterType<ProgressRing>("Spun", 1, 0, "ProgressRing");
@@ -1624,6 +1636,7 @@ int main(int argc, char **argv) {
++frames;
});
});
+ if(test) player.setShowPlayerBody(false);
engine.load(QUrl("qrc:/qml/Main.qml"));
qmlReady = startup.elapsed();
if (engine.rootObjects().isEmpty()) return 1;
diff --git a/src/mediauitest.cpp b/src/mediauitest.cpp
index d89e9d5..2a14ce8 100644
--- a/src/mediauitest.cpp
+++ b/src/mediauitest.cpp
@@ -1,5 +1,7 @@
#include "mediauitest.h"
#include "player.h"
+#include "disc.h"
+#include <QQmlContext>
#include <QQuickWindow>
#include <QQuickItem>
#include <QQuickItemGrabResult>
@@ -30,7 +32,7 @@ int exerciseMediaUi(Player &player, QQuickWindow *window, const QString &temp, c
auto grab=window->contentItem()->grabToImage();
check(grab&&wait([&]{return !grab->image().isNull();})&&grab->image().save(captures+"/"+name+".png"),"media capture saved");
};
- player.setVolume(0);player.setMotion(false);window->setProperty("useCider",false);
+ player.setShowPlayerBody(true);player.setVolume(0);player.setMotion(false);window->setProperty("useCider",false);
QList<QUrl> files;
for(int i=0;i<3;++i){
const auto path=temp+QString("/record-%1.flac").arg(i);
@@ -82,5 +84,87 @@ int exerciseMediaUi(Player &player, QQuickWindow *window, const QString &temp, c
check(item("cassetteReel0")&&window->mask().contains(QPoint(window->width()/2,window->height()/2)),"Mini cassette keeps its reels inside the native input mask");
player.setMotion(false);const double stopped=window->property("cassetteLeftAngle").toDouble();QTest::qWait(100);
check(window->property("cassetteLeftAngle").toDouble()==stopped,"reduced motion freezes cassette winding");
+ player.setMiniMode(false);player.setVinylAlbumMode(false);player.pause();
+ const auto deckPos=item("playerDeck")->mapToScene(QPointF());
+ const auto barPos=item("sourceBar")->mapToScene(QPointF());
+ for(const auto &medium:QStringList{"cd","vinyl","cassette"}) {
+ player.setMedium(medium);player.setShowPlayerBody(true);QTest::qWait(200);
+ check(item("playerBody")&&item("playerBody")->isVisible(),"full mode shows the selected player housing");
+ check(item("playerDeck")->mapToScene(QPointF())==deckPos&&item("sourceBar")->mapToScene(QPointF())==barPos,"hardware keeps the existing playback and source controls aligned");
+ capture("body-"+medium);
+ window->setProperty("discFlipped",true);QTest::qWait(100);capture("booklet-"+medium);
+ check(!item("playerLid")->isVisible(),"album booklet keeps the lid away from track and lyric controls");
+ check(item("albumTrackList")->height()>140,"album booklet gives tracks a full reading area");
+ check(item("discBackFooter")->mapToScene(QPointF(0,36)).y()<item("albumBooklet")->mapToScene(QPointF(0,400)).y(),"booklet footer stays inside the physical case with bottom padding");
+ check(item("cassetteSeek")->isVisible()&&!item("progressRing")->isVisible(),"booklet uses a horizontal seek bar within the case");
+ const auto bookSeek=item("cassetteSeek")->mapToScene(QPointF(80,18)).toPoint();
+ QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,bookSeek);
+ check(wait([&]{return qAbs(player.position()-player.duration()*.25)<1200;}),"booklet progress bar seeks the current song");
+ window->setProperty("discFlipped",false);
+ player.setShowPlayerBody(false);QTest::qWait(50);
+ check(!item("playerBody")->isVisible()&&window->property("mediumScale").toDouble()==1.,"body toggle restores the original medium geometry");
+ player.setShowPlayerBody(true);player.setMiniMode(true);QTest::qWait(80);
+ check(!item("playerBody")->isVisible(),"Mini mode retains its compact silhouette");player.setMiniMode(false);
+ }
+ player.setMedium("cassette");
+ for(const auto &finish:QStringList{"clear","smoke","cream"}) { player.setCassetteFinish(finish);QTest::qWait(100);capture("cassette-"+finish); }
+ player.setCassetteFinish("invalid");check(player.cassetteFinish()=="cream","invalid cassette finishes cannot replace the saved selection");
+ {Player restored(temp+"/player.ini");check(restored.showPlayerBody()&&restored.cassetteFinish()=="cream","player body and cassette finish preferences survive relaunch");}
+ auto *typography=qmlContext(window)->contextProperty("typography").value<QObject*>();
+ player.setMedium("vinyl");
+ for(double zoom:{.85,1.,1.5}) {
+ typography->setProperty("uiScale",zoom);QTest::qWait(100);
+ auto *scrub=item("scrubber");const auto point=scrub->mapToScene(QPointF(436,220)).toPoint();
+ QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,point);
+ check(wait([&]{return qAbs(player.position()-player.duration()*.25)<700;}),"scaled player housing preserves accurate circular seeking");
+ }
+ typography->setProperty("uiScale",1.);QTest::qWait(100);
+ check(item("tonearmLoader")->z()>item("progressRing")->z(),"tonearm hardware occludes the waveform instead of being crossed by it");
+ QTest::mouseMove(window,QPoint(25,15));
+ player.setMotion(true);player.play();QTest::qWait(200);capture("vinyl-playing");player.pause();
+
+ auto *presentation=qobject_cast<DiscPresentation*>(qmlContext(window)->contextProperty("presentation").value<QObject*>());
+ int swaps=0;QObject::connect(presentation,&DiscPresentation::swapRequested,presentation,[&]{++swaps;});
+ player.setMotion(true);player.setMedium("cd");
+ check(!player.cd500Rpm()&&window->property("cdDegreesPerSecond").toDouble()==9,"CD retains its gentle rotation by default");
+ auto *preferences=window->findChild<QObject*>("preferencesPopup");
+ if(preferences)QMetaObject::invokeMethod(preferences,"open");
+ QTest::qWait(220);
+ auto *speedToggle=item("cd500RpmToggle");
+ check(speedToggle&&speedToggle->isVisible(),"CD preferences expose the 500 RPM toggle");
+ if(speedToggle)QTest::mouseClick(window,Qt::LeftButton,Qt::NoModifier,speedToggle->mapToScene(QPointF(speedToggle->width()-32,speedToggle->height()/2)).toPoint());
+ check(player.cd500Rpm(),"clicking the CD speed toggle enables fast rotation");QTest::qWait(300);capture("cd-speed-settings");
+ player.setMedium("vinyl");QTest::qWait(30);
+ check(speedToggle&&!speedToggle->isVisible()&&window->property("spinSpeed").toDouble()==0,"CD setting stays hidden in vinyl mode and does not carry over its rotation");
+ player.setMedium("cd");if(preferences)QMetaObject::invokeMethod(preferences,"close");QTest::qWait(220);
+ check(window->property("cdDegreesPerSecond").toDouble()==3000,"500 RPM converts to 3000 degrees per second");
+ {Player restored(temp+"/player.ini");check(restored.cd500Rpm(),"CD speed preference survives relaunch");}
+ player.play();
+ if(window->isExposed())check(wait([&]{return window->property("spinSpeed").toDouble()>2900;}),"playing CD accelerates to the selected 500 RPM");
+ else {const auto angle=window->property("spinAngle");QTest::qWait(80);check(window->property("spinAngle")==angle,"hidden 500 RPM CD does not animate");}
+ player.setMotion(false);const auto cdAngle=window->property("spinAngle");QTest::qWait(80);
+ check(window->property("spinAngle")==cdAngle,"reduced motion freezes the 500 RPM CD");
+ player.pause();player.setCd500Rpm(false);player.setMotion(true);
+
+ presentation->present(player.artwork(),"fixture-album-one",false);
+ presentation->present(player.artwork(),"fixture-album-two",true);QTest::qWait(150);
+ if(window->isExposed())check(window->property("swapRunning").toBool()&&window->property("packageOpacity").toDouble()>0,"album exchange presents its packaging and opens the lid");
+ capture("album-loading");
+ player.play();check(wait([&]{return player.playing();}),"packaging animation never delays playback");player.pause();
+ presentation->present(player.artwork(),"fixture-album-two",true);
+ check(swaps==1,"same-album updates do not exchange the physical medium");
+ player.setMotion(false);QTest::qWait(30);
+ check(!window->property("swapRunning").toBool()&&window->property("lidOpen").toDouble()==0,"reduced motion interrupts loading and closes the lid");
+ QObject::disconnect(presentation,&DiscPresentation::swapRequested,presentation,nullptr);
+ QFile palette(temp+"/config/gtk-4.0/noctalia.css");
+ if(palette.open(QIODevice::ReadOnly)) {
+ const auto original=palette.readAll();palette.close();auto light=original;
+ light.replace("#17191f","#f6f0e8").replace("#eee5dc","#342d29").replace("#e6b599","#8b492d").replace("#392619","#ffffff").replace("#24252b","#e9e0d5");
+ if(palette.open(QIODevice::WriteOnly|QIODevice::Truncate)){palette.write(light);palette.close();}
+ check(wait([&]{return window->property("surface").value<QColor>().lightness()>128;}),"physical housings follow the light Noctalia palette");
+ for(const auto &medium:QStringList{"cd","vinyl","cassette"}){player.setMedium(medium);QTest::qWait(100);capture("light-"+medium);}
+ if(palette.open(QIODevice::WriteOnly|QIODevice::Truncate)){palette.write(original);palette.close();}
+ }
+
std::cout<<"MEDIA UI RESULT "<<failures<<" failures"<<std::endl;return failures?1:0;
}
diff --git a/src/player.cpp b/src/player.cpp
index 6ac00db..8d8b981 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -41,8 +41,12 @@ Player::Player(const QString &settingsPath, QObject *parent)
m_light = m_settings.value("light", false).toBool();
m_medium=m_settings.value("medium",m_settings.value("vinyl",false).toBool()?"vinyl":"cd").toString();
if(!QStringList{"cd","vinyl","cassette"}.contains(m_medium))m_medium="cd";
+ m_cd500Rpm=m_settings.value("cd500Rpm",false).toBool();
m_vinylSpeed=m_settings.value("vinylSpeed",33).toInt();
if(m_vinylSpeed!=0&&m_vinylSpeed!=33&&m_vinylSpeed!=45)m_vinylSpeed=33;
+ m_showPlayerBody=m_settings.value("showPlayerBody",true).toBool();
+ m_cassetteFinish=m_settings.value("cassetteFinish","smoke").toString();
+ if(!QStringList{"clear","smoke","cream"}.contains(m_cassetteFinish))m_cassetteFinish="smoke";
m_vinylAlbumMode=m_settings.value("vinylAlbumMode",false).toBool();
m_horizontalSeek=m_settings.value("horizontalSeek",false).toBool();
m_vinylCrackle=m_settings.value("vinylCrackle",false).toBool();
@@ -471,6 +475,9 @@ void Player::setMedium(const QString &value) {
if(m_medium==value || !QStringList{"cd","vinyl","cassette"}.contains(value))return;
const bool wasVinyl=vinyl();m_medium=value;emit mediumChanged();if(wasVinyl!=vinyl())emit vinylChanged();save();
}
+void Player::setShowPlayerBody(bool value) { if(value==m_showPlayerBody)return;m_showPlayerBody=value;emit settingsChanged();save(); }
+void Player::setCassetteFinish(const QString &value) { if(value==m_cassetteFinish || !QStringList{"clear","smoke","cream"}.contains(value))return;m_cassetteFinish=value;emit settingsChanged();save(); }
+void Player::setCd500Rpm(bool value) { if(value==m_cd500Rpm)return;m_cd500Rpm=value;emit settingsChanged();save(); }
void Player::setVinylSpeed(int value) { if((value!=0&&value!=33&&value!=45)||value==m_vinylSpeed)return;m_vinylSpeed=value;emit settingsChanged();save(); }
void Player::setHorizontalSeek(bool value) { if(value==m_horizontalSeek)return;m_horizontalSeek=value;emit settingsChanged();save(); }
void Player::setVinylCrackle(bool value) { if(value==m_vinylCrackle)return;m_vinylCrackle=value;emit settingsChanged();save(); }
@@ -489,8 +496,11 @@ void Player::save() {
m_settings.setValue("medium", m_medium);
m_settings.setValue("motion", m_motion);
m_settings.setValue("cassetteSounds", m_cassetteSounds);
+ m_settings.setValue("cd500Rpm",m_cd500Rpm);
m_settings.setValue("vinylSpeed",m_vinylSpeed);
m_settings.setValue("vinylAlbumMode",m_vinylAlbumMode);
+ m_settings.setValue("showPlayerBody",m_showPlayerBody);
+ m_settings.setValue("cassetteFinish",m_cassetteFinish);
m_settings.setValue("horizontalSeek",m_horizontalSeek);
m_settings.setValue("vinylCrackle",m_vinylCrackle);
m_settings.setValue("vinylStatic",m_vinylStatic);
diff --git a/src/player.h b/src/player.h
index bf086e3..4b929e7 100644
--- a/src/player.h
+++ b/src/player.h
@@ -23,8 +23,11 @@ struct ImportedTracks { QList<Track> tracks; QString firstPath; };
class Player : public QObject {
Q_OBJECT
Q_PROPERTY(QString trackKey READ trackKey NOTIFY trackChanged)
+ Q_PROPERTY(bool cd500Rpm READ cd500Rpm WRITE setCd500Rpm NOTIFY settingsChanged)
Q_PROPERTY(int vinylSpeed READ vinylSpeed WRITE setVinylSpeed NOTIFY settingsChanged)
Q_PROPERTY(bool vinylAlbumMode READ vinylAlbumMode WRITE setVinylAlbumMode NOTIFY settingsChanged)
+ Q_PROPERTY(bool showPlayerBody READ showPlayerBody WRITE setShowPlayerBody NOTIFY settingsChanged)
+ Q_PROPERTY(QString cassetteFinish READ cassetteFinish WRITE setCassetteFinish NOTIFY settingsChanged)
Q_PROPERTY(bool horizontalSeek READ horizontalSeek WRITE setHorizontalSeek NOTIFY settingsChanged)
Q_PROPERTY(bool vinylCrackle READ vinylCrackle WRITE setVinylCrackle NOTIFY settingsChanged)
Q_PROPERTY(bool vinylStatic READ vinylStatic WRITE setVinylStatic NOTIFY settingsChanged)
@@ -62,9 +65,15 @@ public:
explicit Player(const QString &settingsPath, QObject *parent = nullptr);
~Player() override;
QString trackKey() const { return currentUrl().toString(); }
+ bool cd500Rpm() const { return m_cd500Rpm; }
+ void setCd500Rpm(bool value);
int vinylSpeed() const { return m_vinylSpeed; }
bool horizontalSeek() const { return m_horizontalSeek; }
bool vinylCrackle() const { return m_vinylCrackle; }
+ bool showPlayerBody() const { return m_showPlayerBody; }
+ void setShowPlayerBody(bool value);
+ QString cassetteFinish() const { return m_cassetteFinish; }
+ void setCassetteFinish(const QString &value);
bool vinylStatic() const { return m_vinylStatic; }
bool vinylSkips() const { return m_vinylSkips; }
void setVinylSpeed(int value);
@@ -182,8 +191,11 @@ private:
QSet<QString> m_shuffleVisited;
QString m_artFile, m_error;
bool m_ciderAutoStart = false;
+ bool m_cd500Rpm=false;
int m_vinylSpeed=33;
bool m_vinylAlbumMode=false;
+ bool m_showPlayerBody=true;
+ QString m_cassetteFinish="smoke";
bool m_horizontalSeek=false, m_vinylCrackle=false, m_vinylStatic=false, m_vinylSkips=false;
bool m_cassetteSounds=true;
QString m_medium = "cd";
diff --git a/src/playerbody.cpp b/src/playerbody.cpp
new file mode 100644
index 0000000..f82f790
--- /dev/null
+++ b/src/playerbody.cpp
@@ -0,0 +1,133 @@
+#include "playerbody.h"
+#include <QPainter>
+#include <QPainterPath>
+#include <QLinearGradient>
+#include <QRadialGradient>
+#include <QConicalGradient>
+#include <QRandomGenerator>
+
+void PlayerBody::paint(QPainter *p) {
+ p->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
+ p->scale(width()/440.,height()/440.);
+ const bool tape=m_medium=="cassette",cd=m_medium=="cd";
+ const auto metal=[&](const QRectF &r,qreal radius){
+ // Broad face, rounded bevel and a dark underside share one light source.
+ const QColor base=m_surface;
+ p->setPen(Qt::NoPen);p->setBrush(base.darker(210));
+ p->drawRoundedRect(r,radius,radius);
+ QLinearGradient edge(r.topLeft(),r.bottomRight());
+ edge.setColorAt(0,base.lighter(165));edge.setColorAt(.26,base.lighter(115));
+ edge.setColorAt(.64,base.darker(160));edge.setColorAt(1,base.darker(230));
+ p->setBrush(edge);p->drawRoundedRect(r.adjusted(.7,.5,-.7,-1.7),radius,radius);
+ const QRectF face=r.adjusted(2,2,-2,-5);
+ QLinearGradient g(face.topLeft(),face.bottomRight());
+ g.setColorAt(0,base.lighter(130));g.setColorAt(.35,base.lighter(112));
+ g.setColorAt(1,base.darker(115));
+ p->setBrush(g);p->drawRoundedRect(face,qMax(1.,radius-2),qMax(1.,radius-2));
+ p->setBrush(Qt::NoBrush);p->setPen(QPen(QColor(245,249,255,45),.65));
+ p->drawRoundedRect(r.adjusted(1,1,-1,-2),radius,radius);
+ };
+ const auto screw=[&](QPointF at){
+ p->setPen(Qt::NoPen);p->setBrush(QColor(0,0,0,135));p->drawEllipse(at+QPointF(0,.8),4.4,4.4);
+ QConicalGradient g(at,35);g.setColorAt(0,QColor("#c4c7c6"));g.setColorAt(.25,QColor("#4a4f51"));g.setColorAt(.55,QColor("#b0b7b9"));g.setColorAt(.8,QColor("#303639"));g.setColorAt(1,QColor("#c4c7c6"));
+ p->setPen(QPen(QColor(0,0,0,170),.65));p->setBrush(g);p->drawEllipse(at,3.1,3.1);
+ p->setPen(QPen(QColor(0,0,0,210),.85));
+ p->drawLine(at+QPointF(-1.5,1.5),at+QPointF(1.5,-1.5));
+ p->drawLine(at+QPointF(-1.5,-1.5),at+QPointF(1.5,1.5));
+ };
+ const auto glassEdge=[&](const QPainterPath &path){
+ p->setBrush(Qt::NoBrush);p->setPen(QPen(QColor(0,0,0,145),4));p->drawPath(path.translated(0,1.5));
+ p->setPen(QPen(QColor(171,197,203,65),2.1));p->drawPath(path);
+ p->setPen(QPen(QColor(244,251,255,80),.55));p->drawPath(path.translated(-.35,-.65));
+ };
+ const auto hinge=[&](QRectF r){
+ QLinearGradient chrome(r.topLeft(),r.bottomLeft());
+ chrome.setColorAt(0,QColor("#262b2d"));chrome.setColorAt(.22,QColor("#c1c5c3"));
+ chrome.setColorAt(.45,QColor("#747b7c"));chrome.setColorAt(.78,QColor("#303637"));chrome.setColorAt(1,QColor("#151a1b"));
+ p->setPen(QPen(QColor(0,0,0,170),.6));p->setBrush(chrome);p->drawRoundedRect(r,2,2);
+ p->setPen(QPen(QColor(0,0,0,120),.7));
+ for(double x=r.left()+4;x<r.right();x+=5)p->drawLine(QPointF(x,r.top()+1),QPointF(x,r.bottom()-1));
+ };
+ if(m_layer>=2) {
+ const QRectF r=m_layer==3 ? QRectF(30,20,380,410) : tape?QRectF(40,106,360,228):QRectF(44,44,352,352);
+ p->setPen(Qt::NoPen);p->setBrush(QColor(0,0,0,100));p->drawRoundedRect(r.translated(2,5),5,5);
+ metal(r,cd?5:2);
+ const QRectF cover=r.adjusted(cd?18:5,5,-5,-5);
+ if(!m_artwork.isNull()) {
+ const auto side=qMin(m_artwork.width(),m_artwork.height());
+ p->drawImage(cover,m_artwork,QRectF((m_artwork.width()-side)/2.,(m_artwork.height()-side)/2.,side,side));
+ }
+ if(cd){
+ p->fillRect(QRectF(r.x()+3,r.y()+5,10,r.height()-10),QColor(180,193,199,70));
+ p->setPen(QPen(QColor(240,250,255,95),.6));
+ for(int x=0;x<5;++x)p->drawLine(QPointF(r.x()+4+x*2,r.top()+6),QPointF(r.x()+4+x*2,r.bottom()-6));
+ }else if(!tape){
+ p->setPen(QPen(QColor(0,0,0,65),1));p->drawLine(r.topRight()-QPointF(2,0),r.bottomRight()-QPointF(2,0));
+ }
+ QLinearGradient gloss(r.topLeft(),r.bottomRight());gloss.setColorAt(0,QColor(255,255,255,cd?40:12));gloss.setColorAt(.48,Qt::transparent);gloss.setColorAt(.5,QColor(255,255,255,cd?16:4));gloss.setColorAt(1,Qt::transparent);
+ p->fillRect(r.adjusted(1,1,-1,-1),gloss);return;
+ }
+ if(m_layer==1) {
+ if(m_medium=="vinyl") {
+ QLinearGradient acrylic(0,8,0,63);acrylic.setColorAt(0,QColor(222,236,242,18));acrylic.setColorAt(1,QColor(204,225,237,2));
+ p->setBrush(acrylic);p->setPen(QPen(QColor(220,235,243,48),.8));p->drawRoundedRect(QRectF(15,9,410,51),7,7);
+ hinge(QRectF(69,9,24,7));hinge(QRectF(347,9,24,7));
+ // The spindle belongs to the deck and remains stationary above the label.
+ QRadialGradient spindle(QPointF(218.5,217),6);spindle.setColorAt(0,QColor("#e6ebed"));spindle.setColorAt(.5,QColor("#a5abad"));spindle.setColorAt(.8,QColor("#50585d"));spindle.setColorAt(1,QColor("#20272b"));
+ p->setPen(Qt::NoPen);p->setBrush(QColor(0,0,0,125));p->drawEllipse(QPointF(221,222),6,6);
+ p->setBrush(spindle);p->drawEllipse(QPointF(220,220),4.5,5.5);return;
+ }
+ QPainterPath glass;
+ if(tape)glass.addRoundedRect(QRectF(42,112,356,225),12,12);
+ else glass.addEllipse(QPointF(220,220),194,194);
+ QLinearGradient g(60,70,345,365);g.setColorAt(0,QColor(219,237,244,32));g.setColorAt(.32,QColor(200,220,230,2));g.setColorAt(.33,QColor(243,250,255,22));g.setColorAt(.48,QColor(235,247,255,4));g.setColorAt(1,QColor(8,12,18,30));
+ p->fillPath(glass,g);glassEdge(glass);
+ p->save();p->setClipPath(glass);
+ // Restrained hairline scuffs catch the same overhead light as the bevel.
+ p->setPen(QPen(QColor(241,246,247,13),.45));
+ for(int i=0;i<11;++i){const double x=65+i*27;const double y=tape?124+(i%4)*4:71+(i%4)*5;p->drawLine(QPointF(x,y),QPointF(x+12+(i%3)*6,y-2));}
+ p->restore();
+ if(tape){hinge(QRectF(80,107,31,8));hinge(QRectF(329,107,31,8));metal(QRectF(195,334,50,9),3);}
+ else{
+ hinge(QRectF(159,26,24,8));hinge(QRectF(257,26,24,8));
+ QConicalGradient clamp(QPointF(220,220),25);clamp.setColorAt(0,QColor("#b8bfc0"));clamp.setColorAt(.4,QColor("#45494d"));clamp.setColorAt(.7,QColor("#dae0df"));clamp.setColorAt(1,QColor("#b8bfc0"));
+ p->setPen(QPen(QColor(0,0,0,180),1));p->setBrush(clamp);p->drawEllipse(QPointF(220,220),21,21);
+ p->setBrush(Qt::NoBrush);p->setPen(QPen(QColor(235,242,241,55),.7));
+ p->drawEllipse(QPointF(220,220),18,18);p->drawEllipse(QPointF(220,220),15,15);
+ p->setBrush(QColor("#303338"));p->setPen(QPen(QColor(0,0,0,150),.8));p->drawEllipse(QPointF(220,220),8,8);
+ }
+ return;
+ }
+ const QRectF body=tape?QRectF(19,83,402,283):QRectF(6,6,428,428);
+ p->setPen(Qt::NoPen);
+ for(int i=6;i>0;--i){p->setBrush(QColor(0,0,0,7));p->drawRoundedRect(body.adjusted(-i,-i,i,i).translated(0,3),cd?220:23,cd?220:23);}
+ metal(body,cd?214:22);
+ p->save();QPainterPath face;face.addRoundedRect(body.adjusted(3,3,-3,-7),cd?211:20,cd?211:20);p->setClipPath(face);
+ QRandomGenerator grain(317);
+ for(int i=0;i<2600;++i){
+ const double x=body.left()+grain.generateDouble()*body.width(),y=body.top()+grain.generateDouble()*body.height();
+ p->setPen(QPen(i%3?QColor(255,255,255,7):QColor(0,0,0,18),.45));
+ p->drawLine(QPointF(x,y),QPointF(x+(tape?1.2:3.5),y));
+ }
+ // A broad reflected light distinguishes the face from its rounded sidewall.
+ QRadialGradient light(QPointF(70,30),390);light.setColorAt(0,QColor(237,244,255,16));light.setColorAt(1,Qt::transparent);
+ p->fillPath(face,light);p->restore();
+ if(tape){
+ p->setPen(QPen(QColor(0,0,0,200),2));p->setBrush(QColor("#15171a"));p->drawRoundedRect(QRectF(36,102,368,246),15,15);
+ for(int i=0;i<4;++i){p->setBrush(Qt::NoBrush);p->setPen(QPen(QColor(0,0,0,45-i*8),1.5));p->drawRoundedRect(QRectF(33-i,99-i,374+2*i,252+2*i),17+i,17+i);}
+ p->setPen(QPen(QColor(226,238,242,32),.7));p->drawRoundedRect(QRectF(34,100,372,250),17,17);
+ screw(QPointF(29,96));screw(QPointF(411,96));screw(QPointF(29,354));screw(QPointF(411,354));
+ for(int x=0;x<11;++x){p->setPen(QPen(QColor(0,0,0,85),1));p->drawLine(QPointF(176+x*9,358),QPointF(176+x*9,361));}
+ }else{
+ QRadialGradient recess(QPointF(220,220),197);recess.setColorAt(0,QColor("#16181b"));recess.setColorAt(.95,QColor("#16181b"));recess.setColorAt(.98,QColor("#090b0d"));recess.setColorAt(1,QColor(0,0,0,0));
+ p->setPen(Qt::NoPen);p->setBrush(recess);p->drawEllipse(QPointF(220,220),198,198);
+ p->setBrush(Qt::NoBrush);p->setPen(QPen(QColor("#656a6b"),2));p->drawEllipse(QPointF(220,220),187,187);
+ p->setPen(QPen(QColor("#181b1d"),5));p->drawEllipse(QPointF(220,220),183,183);
+ if(!cd){
+ for(int r:{185,188,191})for(int i=0;i<120;++i){p->save();p->translate(220,220);p->rotate(i*3+(r%2)*1.5);p->setPen(Qt::NoPen);p->setBrush(QColor(185,192,193,r==188?100:50));p->drawEllipse(QPointF(0,-r),.7,1.05);p->restore();}
+ p->setPen(QPen(QColor(221,231,236,42),.8));p->setBrush(Qt::NoBrush);p->drawEllipse(QPointF(220,220),193,193);
+ screw(QPointF(20,20));screw(QPointF(420,20));screw(QPointF(20,420));screw(QPointF(420,420));
+ metal(QRectF(37,391,34,8),4);metal(QRectF(365,31,25,11),3);
+ }else metal(QRectF(195,410,50,9),4);
+ }
+}
diff --git a/src/playerbody.h b/src/playerbody.h
new file mode 100644
index 0000000..f9daa72
--- /dev/null
+++ b/src/playerbody.h
@@ -0,0 +1,24 @@
+#pragma once
+#include <QQuickPaintedItem>
+#include <QImage>
+
+// Static physical surfaces remain cached while the scene graph moves the media.
+class PlayerBody : public QQuickPaintedItem {
+ Q_OBJECT
+ Q_PROPERTY(QString medium MEMBER m_medium NOTIFY changed)
+ Q_PROPERTY(QColor surface MEMBER m_surface NOTIFY changed)
+ Q_PROPERTY(QImage artwork MEMBER m_artwork NOTIFY changed)
+ Q_PROPERTY(int part MEMBER m_layer NOTIFY changed)
+public:
+ explicit PlayerBody(QQuickItem *parent=nullptr):QQuickPaintedItem(parent) {
+ setAntialiasing(true);connect(this,&PlayerBody::changed,this,[this]{update();});
+ }
+ void paint(QPainter *painter) override;
+signals:
+ void changed();
+private:
+ QString m_medium="vinyl";
+ QColor m_surface=QColor("#343438");
+ QImage m_artwork;
+ int m_layer=0;
+};