mpris
This commit is contained in:
parent
653f5814b3
commit
2852735d70
4 changed files with 96 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ Singleton {
|
|||
property int radius: 8
|
||||
|
||||
property Bar bar: Bar {}
|
||||
property Mpris mpris: Mpris {}
|
||||
property Clock clock: Clock {}
|
||||
property Workspace workspace: Workspace {}
|
||||
|
||||
|
|
@ -24,6 +25,15 @@ Singleton {
|
|||
property int horizontalPadding: 8
|
||||
}
|
||||
|
||||
component Mpris: QtObject {
|
||||
id: clock
|
||||
|
||||
property int fontSize: 14
|
||||
property int height: 30
|
||||
property int horizontalPadding: 8
|
||||
property int verticalPadding: 6
|
||||
}
|
||||
|
||||
component Clock: QtObject {
|
||||
id: clock
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ Scope {
|
|||
anchors.bottomMargin: Dimensions.bar.verticalPadding
|
||||
|
||||
spacing: Dimensions.bar.spacing
|
||||
|
||||
Mpris {}
|
||||
}
|
||||
|
||||
Row {
|
||||
|
|
|
|||
29
modules/bar/components/Mpris.qml
Normal file
29
modules/bar/components/Mpris.qml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import Quickshell
|
||||
import Quickshell.Services.Mpris
|
||||
import QtQuick
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property int currentIndex: 0
|
||||
|
||||
implicitWidth: childrenRect.width
|
||||
implicitHeight: childrenRect.height
|
||||
|
||||
Repeater {
|
||||
id: players
|
||||
model: Mpris.players.values.filter(item => item != null)
|
||||
|
||||
Player {
|
||||
|
||||
visible: index === root.currentIndex && modelData.canControl
|
||||
|
||||
onNextPlayer: {
|
||||
currentIndex = (currentIndex + 1) % players.count;
|
||||
}
|
||||
onPreviousPlayer: {
|
||||
currentIndex = (currentIndex - 1 + players.count) % players.count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
modules/bar/components/Player.qml
Normal file
55
modules/bar/components/Player.qml
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import Quickshell
|
||||
import Quickshell.Services.Mpris
|
||||
import QtQuick
|
||||
import "../../../styled/"
|
||||
import "../../../config/"
|
||||
|
||||
Item {
|
||||
required property MprisPlayer modelData
|
||||
required property int index
|
||||
|
||||
signal nextPlayer()
|
||||
signal previousPlayer()
|
||||
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
implicitWidth: childrenRect.width
|
||||
implicitHeight: Dimensions.mpris.height
|
||||
|
||||
StyledLabel {
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: `${modelData.isPlaying ? "" : ""} ${modelData.trackTitle} - ${modelData.trackArtist}`
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
topPadding: Dimensions.mpris.verticalPadding
|
||||
bottomPadding: Dimensions.mpris.verticalPadding
|
||||
leftPadding: Dimensions.mpris.horizontalPadding
|
||||
rightPadding: Dimensions.mpris.horizontalPadding
|
||||
|
||||
font.pixelSize: Dimensions.mpris.fontSize
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
||||
onClicked: {
|
||||
if (!modelData.canTogglePlaying) {
|
||||
return;
|
||||
}
|
||||
if (modelData.isPlaying) {
|
||||
modelData.pause();
|
||||
} else {
|
||||
modelData.play();
|
||||
}
|
||||
}
|
||||
onWheel: event => {
|
||||
if (event.angleDelta.y > 0) {
|
||||
parent.nextPlayer();
|
||||
} else if (event.angleDelta.y < 0) {
|
||||
parent.previousPlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue