shift-shell/components/mobileshell/qml/widgets/mediacontrols/MediaControlsSource.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.3 KiB
QML
Raw Normal View History

2023-09-27 05:41:52 +00:00
// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
// SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick
2023-09-27 05:41:52 +00:00
import org.kde.plasma.private.mpris as Mpris
import org.kde.kitemmodels
2023-09-27 05:41:52 +00:00
QtObject {
property var baseMpris2Model: Mpris.Mpris2Model {}
property var mpris2Model: KSortFilterProxyModel {
sourceModel: baseMpris2Model
2023-09-27 05:41:52 +00:00
// filter and ignore first element, because it's the multiplexer (which will look like a duplicate source)
filterRowCallback: function(source_row, source_parent) {
return source_row !== 0;
}
}
function startOperation(src, op) {
var service = serviceForSource(src)
var operation = service.operationDescription(op)
return service.startOperationCall(operation)
}
2023-09-27 05:41:52 +00:00
function setIndex(index) {
baseMpris2Model.currentIndex = index + 1; // account for first row being gone (multiplexer)
}
2023-09-27 05:41:52 +00:00
function goPrevious() {
baseMpris2Model.currentPlayer.Previous();
}
2023-09-27 05:41:52 +00:00
function goNext() {
baseMpris2Model.currentPlayer.Next();
}
2023-09-27 05:41:52 +00:00
function playPause() {
baseMpris2Model.currentPlayer.PlayPause();
}
function updatePosition(): void {
baseMpris2Model.currentPlayer.updatePosition();
}
}