aurora7a221ea
aurora: replay mpd's last track on empty queue, no wheel on sliders
+20 −8
4 files changed
- M .config/quickshell/aurora/BarSlider.qml +2 −5
- M .config/quickshell/aurora/Media.qml +15 −0
- M .config/quickshell/aurora/PlayControls.qml +1 −1
- M .config/quickshell/aurora/SliderRow.qml +2 −2
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | import QtQuick | |
| 2 | 2 | ||
| 3 | 3 | // Dotted slider: a row of LED dots, the lit part white up to a larger head dot, the rest unlit. | |
| 4 | − | // Click/drag sets, the wheel steps. muted = the lit dots go grey. | |
| 4 | + | // Click/drag sets, the wheel scrolls the page past it. muted = the lit dots go grey. | |
| 5 | 5 | Item { | |
| 6 | 6 | id: s | |
| 7 | 7 | property real value: 0 | |
| @@ -42,9 +42,6 @@ Item { | |||
| 42 | 42 | } | |
| 43 | 43 | onPressed: m => setFromX(m.x) | |
| 44 | 44 | onPositionChanged: m => { if (pressed) setFromX(m.x) } | |
| 45 | − | onWheel: w => { | |
| 46 | − | var d = (w.angleDelta.y > 0 ? 1 : -1) * s.step * (s.to - s.from) | |
| 47 | − | s.moved(Math.max(s.from, Math.min(s.to, s.value + d))) | |
| 48 | − | } | |
| 45 | + | // no onWheel: a MouseArea without one passes the wheel on, so scrolling the page never moves a slider | |
| 49 | 46 | } | |
| 50 | 47 | } | |
| @@ -20,6 +20,21 @@ Singleton { | |||
| 20 | 20 | readonly property bool playing: player !== null && player.isPlaying | |
| 21 | 21 | readonly property bool seekable: player !== null && player.lengthSupported && player.length > 0 | |
| 22 | 22 | ||
| 23 | + | // Play/pause. mpd-mpris says CanPlay with an empty queue (it keeps the last track's metadata, trackid NoTrack), | |
| 24 | + | // so Play does nothing there: queue the track the card still shows again (mpc, MPRIS has no queue API). | |
| 25 | + | function toggle(p) { | |
| 26 | + | if (!p || !p.canTogglePlaying) return | |
| 27 | + | var md = p.metadata || {} | |
| 28 | + | var noTrack = String(md["mpris:trackid"] || "").endsWith("/NoTrack") | |
| 29 | + | if (!p.isPlaying && noTrack && p.dbusName === "org.mpris.MediaPlayer2.mpd" && p.trackTitle) { | |
| 30 | + | var q = ["title", p.trackTitle] | |
| 31 | + | if (p.trackAlbum) q.push("album", p.trackAlbum) | |
| 32 | + | Quickshell.execDetached(["sh", "-c", 'mpc -q findadd "$@" && mpc -q play', "sh"].concat(q)) | |
| 33 | + | return | |
| 34 | + | } | |
| 35 | + | p.togglePlaying() | |
| 36 | + | } | |
| 37 | + | ||
| 23 | 38 | function fmt(s) { // 75 -> "1:15" | |
| 24 | 39 | s = Math.max(0, Math.floor(s)) | |
| 25 | 40 | var m = Math.floor(s / 60), r = s % 60 | |
| @@ -31,7 +31,7 @@ Row { | |||
| 31 | 31 | font.pixelSize: root.play * 0.46 | |
| 32 | 32 | } | |
| 33 | 33 | HoverHandler { cursorShape: Qt.PointingHandCursor } | |
| 34 | − | TapHandler { onTapped: if (root.player && root.player.canTogglePlaying) root.player.togglePlaying() } | |
| 34 | + | TapHandler { onTapped: Media.toggle(root.player) } | |
| 35 | 35 | } | |
| 36 | 36 | Icon { | |
| 37 | 37 | anchors.verticalCenter: parent.verticalCenter | |
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | import QtQuick | |
| 2 | 2 | ||
| 3 | 3 | // Level slider (control panel): a pill whose filled part is white with the icon in it, the rest a row of dots, | |
| 4 | − | // the value in a chip on the right. Click/drag sets, the wheel steps, the icon end toggles mute (iconClicked). | |
| 4 | + | // the value in a chip on the right. Click/drag sets (the wheel scrolls past it), the icon end toggles mute (iconClicked). | |
| 5 | 5 | // Ported from glyph-rice (github.com/Nebelung-cloud/glyph-rice, GPL-3.0), quick/Quick.qml (Slider). | |
| 6 | 6 | Item { | |
| 7 | 7 | id: r | |
| @@ -65,7 +65,7 @@ Item { | |||
| 65 | 65 | function set(x) { v = Math.max(0, Math.min(1, x / width)); r.moved(v) } | |
| 66 | 66 | onPressed: e => set(e.x) | |
| 67 | 67 | onPositionChanged: e => { if (pressed) set(e.x) } | |
| 68 | − | onWheel: w => r.moved(Math.max(0, Math.min(1, r.value + (w.angleDelta.y > 0 ? 0.02 : -0.02)))) | |
| 68 | + | // no onWheel on purpose: the wheel scrolls the page (it kept changing volume/brightness by accident) | |
| 69 | 69 | } | |
| 70 | 70 | // the icon end: mute | |
| 71 | 71 | MouseArea { | |