change mpris to only show spotify
This commit is contained in:
parent
adf04efc96
commit
798f6a618c
1 changed files with 15 additions and 30 deletions
|
|
@ -8,41 +8,26 @@ import qs.settings
|
|||
|
||||
WrapperRectangle {
|
||||
id: root
|
||||
property MprisPlayer spotify: findSpotify()
|
||||
visible: spotify != null
|
||||
property MprisPlayer spotify: {
|
||||
for (const player of Mpris.players.values) {
|
||||
if (player.identity === "Spotify")
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
visible: spotify !== null && spotify.playbackState === MprisPlaybackState.Playing
|
||||
leftMargin: 8
|
||||
rightMargin: 8
|
||||
color: Colors.base01
|
||||
radius: Config.rounding
|
||||
function findSpotify() {
|
||||
for (let i = 0; i < Mpris.players.values.length; i++) {
|
||||
let current = Mpris.players.values[i];
|
||||
if (current.identity == 'spotify' || 'Spotify') {
|
||||
return current;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
child: RowLayout {
|
||||
MaterialIcon {
|
||||
text: "music_note_2"
|
||||
}
|
||||
return null;
|
||||
}
|
||||
child: WrapperMouseArea {
|
||||
id: clickHandler
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: mouse => {
|
||||
if (mouse.button == Qt.RightButton) {
|
||||
root.spotify.togglePlaying();
|
||||
}
|
||||
}
|
||||
child: RowLayout {
|
||||
MaterialIcon {
|
||||
text: "music_note_2"
|
||||
}
|
||||
StyledText {
|
||||
Layout.maximumWidth: 400
|
||||
text: root.spotify?.trackTitle + " - " + root.spotify?.trackArtists
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
StyledText {
|
||||
Layout.maximumWidth: 400
|
||||
text: root.spotify?.trackTitle + " - " + root.spotify?.trackArtists
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue