Skip to content

Commit

Permalink
Revert "fix: Player sources handling improvements"
Browse files Browse the repository at this point in the history
This reverts commit 0844cbc.

This commit seems to make plasmashell crash when a preferred source is selected (#70)
  • Loading branch information
ccatterina committed Mar 17, 2024
1 parent 597bb84 commit 53570d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
27 changes: 5 additions & 22 deletions src/contents/ui/Player.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,13 @@ QtObject {
id: root

property var mpris2Model: Mpris.Mpris2Model {
readonly property string sourceName: root.sourceName
function chooseCurrentPlayer() {
if (sourceName === "any") {
currentIndex = 0
console.debug("setting current source to multiplex");
return
}

onRowsInserted: (_, rowIndex) => {
const CONTAINER_ROLE = Qt.UserRole + 1
for (let i = 1; i < rowCount(); i++) {
const player = data(index(i, 0), CONTAINER_ROLE)
if (player.desktopEntry === sourceName) {
currentIndex = i
console.debug(`setting current source to ${player.desktopEntry} (index ${i})`);
return;
}
const player = this.data(this.index(rowIndex, 0), CONTAINER_ROLE)
if (player.desktopEntry === root.sourceName) {
this.currentIndex = rowIndex;
}
}
onRowsInserted: {
chooseCurrentPlayer()
}
onSourceNameChanged: {
chooseCurrentPlayer()
}
}

property string sourceName: "any"
Expand Down Expand Up @@ -94,4 +77,4 @@ QtObject {
function setLoopStatus(loopStatus) {
mpris2Model.currentPlayer.loopStatus = loopStatus
}
}
}
8 changes: 2 additions & 6 deletions src/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ import org.kde.plasma.private.mpris as Mpris

PlasmoidItem {
id: widget
Plasmoid.status: PlasmaCore.Types.HiddenStatus
Plasmoid.status: player.ready ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.HiddenStatus

Player {
id: player
sourceName: plasmoid.configuration.sources[plasmoid.configuration.sourceIndex]
onReadyChanged: {
Plasmoid.status = player.ready ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.HiddenStatus
console.debug(`Player ready changed: ${player.ready} -> plasmoid status changed: ${Plasmoid.status}`)
}
}

compactRepresentation: Item {
Expand Down Expand Up @@ -239,4 +235,4 @@ PlasmoidItem {

}
}
}
}

0 comments on commit 53570d4

Please sign in to comment.