extract MprisService singleton, share player state between bar and lock screen
This commit is contained in:
parent
438362c6d1
commit
a7eca009e4
4 changed files with 34 additions and 25 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import QtQuick
|
||||
import Quickshell.Services.Mpris
|
||||
import Quickshell.Services.Pipewire
|
||||
import "../services" as S
|
||||
import "../applets" as C
|
||||
|
|
@ -50,12 +49,7 @@ Item {
|
|||
color: Qt.rgba(S.Theme.base01.r, S.Theme.base01.g, S.Theme.base01.b, 0.7)
|
||||
border.color: Qt.rgba(S.Theme.base03.r, S.Theme.base03.g, S.Theme.base03.b, 0.3)
|
||||
border.width: 1
|
||||
visible: (S.Modules.lock.mpris ?? true) && _mprisPlayer !== null
|
||||
|
||||
readonly property var _mprisPlayers: (Mpris.players.values ?? []).filter(p => p.trackTitle || p.playbackState === MprisPlaybackState.Playing || p.playbackState === MprisPlaybackState.Paused)
|
||||
property int _playerIdx: 0
|
||||
readonly property var _mprisPlayer: _mprisPlayers[_playerIdx] ?? _mprisPlayers[0] ?? null
|
||||
readonly property bool _playing: _mprisPlayer?.playbackState === MprisPlaybackState.Playing
|
||||
visible: (S.Modules.lock.mpris ?? true) && S.MprisService.player !== null
|
||||
|
||||
C.MprisApplet {
|
||||
id: _mprisContent
|
||||
|
|
@ -63,15 +57,13 @@ Item {
|
|||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 8
|
||||
player: _mprisCard._mprisPlayer
|
||||
players: _mprisCard._mprisPlayers
|
||||
playing: _mprisCard._playing
|
||||
playerIdx: _mprisCard._playerIdx
|
||||
player: S.MprisService.player
|
||||
players: S.MprisService.players
|
||||
playing: S.MprisService.playing
|
||||
playerIdx: S.MprisService.playerIdx
|
||||
accentColor: S.Theme.base0D
|
||||
cachedArt: _mprisCard._mprisPlayer?.trackArtUrl ?? ""
|
||||
onPlayerSwitched: idx => {
|
||||
_mprisCard._playerIdx = idx;
|
||||
}
|
||||
cachedArt: S.MprisService.player?.trackArtUrl ?? ""
|
||||
onPlayerSwitched: idx => S.MprisService.switchPlayer(idx)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue