players: persist active player across reloads

This commit is contained in:
2 * r + 2 * t 2025-09-23 23:18:12 +10:00
parent 06f366e27e
commit d79b5b7f71

View file

@ -10,14 +10,22 @@ Singleton {
id: root
readonly property list<MprisPlayer> list: Mpris.players.values
readonly property MprisPlayer active: manualActive ?? list.find(p => getIdentity(p) === Config.services.defaultPlayer) ?? list[0] ?? null
property MprisPlayer manualActive
readonly property MprisPlayer active: props.manualActive ?? list.find(p => getIdentity(p) === Config.services.defaultPlayer) ?? list[0] ?? null
property alias manualActive: props.manualActive
function getIdentity(player: MprisPlayer): string {
const alias = Config.services.playerAliases.find(a => a.from === player.identity);
return alias?.to ?? player.identity;
}
PersistentProperties {
id: props
property MprisPlayer manualActive
reloadableId: "players"
}
CustomShortcut {
name: "mediaToggle"
description: "Toggle media playback"