chore: random fixes

This commit is contained in:
Nydragon 2024-09-28 19:13:36 +02:00
parent 6cd1de8984
commit 2295f26618
Signed by: nydragon
SSH key fingerprint: SHA256:iQnIC12spf4QjWSbarmkD2No1cLMlu6TWoV7K6cYF5g
3 changed files with 8 additions and 4 deletions

View file

@ -8,8 +8,10 @@ Singleton {
id: player id: player
property MprisPlayer current: player.all[player.index] property MprisPlayer current: player.all[player.index]
property var all: Mpris.players.values property var all: Mpris.players.values
property int index: Mpris.players.values.findIndex(p => p.playbackState === MprisPlaybackState.Playing) property int index: {
const ind = Mpris.players.values.findIndex(p => p.playbackState === MprisPlaybackState.Playing);
return ind >= 0 ? ind : 0;
}
property var next: () => { property var next: () => {
player.index = (player.index + 1) % all.length; player.index = (player.index + 1) % all.length;
} }

View file

@ -67,17 +67,19 @@ ColumnLayout {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
BIconButton { BIconButton {
id: loopButton
property var map: [ // property var map: [ //
["media-repeat-none", MprisLoopState.None] // ["media-repeat-none", MprisLoopState.None] //
, ["media-repeat-single", MprisLoopState.Track]// , ["media-repeat-single", MprisLoopState.Track]//
, ["media-playlist-repeat", MprisLoopState.Playlist] // , ["media-playlist-repeat", MprisLoopState.Playlist] //
] ]
property int index: map.findIndex(e => e[1] === Player.current?.loopState) property int index: map.findIndex(e => e[1] === Player.current?.loopState)
source: Quickshell.iconPath(map[index][0]) source: visible ? Quickshell.iconPath(map[index][0]) : ""
onClicked: { onClicked: {
const ind = (index + 1) % map.length; const ind = (index + 1) % map.length;
Player.current.loopState = map[ind][1]; Player.current.loopState = map[ind][1];
} }
visible: 0 <= loopButton.index <= (map.length - 1)
} }
BIconButton { BIconButton {
source: Quickshell.iconPath("media-seek-backward") source: Quickshell.iconPath("media-seek-backward")

View file

@ -29,7 +29,7 @@ PopupWindow {
id: display id: display
x: lbar.width * 1.2 x: lbar.width * 1.2
y: lbar.height * 0.2 y: lbar.width * 0.2
width: 500 width: 500
height: 600 height: 600