move mpris controller
This commit is contained in:
parent
06bbd34b73
commit
4007344d9d
3 changed files with 3 additions and 1 deletions
92
components/composite/MprisController.qml
Normal file
92
components/composite/MprisController.qml
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
|
||||
import qs.components
|
||||
import qs.config
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Services.Mpris
|
||||
|
||||
Loader {
|
||||
id: root
|
||||
|
||||
required property MprisPlayer player
|
||||
|
||||
active: player != null
|
||||
|
||||
sourceComponent: ColumnLayout {
|
||||
spacing: Styling.layout.spacing.xl
|
||||
implicitWidth: 800
|
||||
|
||||
StyledText {
|
||||
id: text
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
font.pixelSize: Styling.typography.textSize.base
|
||||
text: `${root.player.trackTitle} - ${root.player.trackArtist}`
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
StyledIconButton {
|
||||
id: backButton
|
||||
|
||||
text: Styling.lucide.icons.skipBack
|
||||
|
||||
onClicked: {
|
||||
root.player.previous();
|
||||
}
|
||||
}
|
||||
StyledIconButton {
|
||||
id: playPauseButton
|
||||
|
||||
text: root.player.isPlaying ? Styling.lucide.icons.pause : Styling.lucide.icons.play
|
||||
|
||||
onClicked: {
|
||||
root.player.isPlaying = !root.player.isPlaying;
|
||||
}
|
||||
}
|
||||
StyledIconButton {
|
||||
id: forwardButton
|
||||
|
||||
text: Styling.lucide.icons.skipForward
|
||||
|
||||
onClicked: {
|
||||
root.player.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
font.pixelSize: Styling.typography.textSize.sm
|
||||
text: {
|
||||
function formatTime(num) {
|
||||
return Math.floor(num).toString().padStart(2, "0");
|
||||
}
|
||||
return `${formatTime(root.player.position / 60)}:${formatTime(root.player.position % 60)} - ${formatTime(root.player.length / 60)}:${formatTime(root.player.length % 60)}`;
|
||||
}
|
||||
}
|
||||
|
||||
StyledSlider {
|
||||
Layout.fillWidth: true
|
||||
|
||||
from: 0
|
||||
to: root.player.length ?? 0
|
||||
value: root.player.position
|
||||
implicitHeight: 6
|
||||
|
||||
onMoved: {
|
||||
root.player.position = value;
|
||||
}
|
||||
|
||||
Timer {
|
||||
running: root.player.isPlaying
|
||||
interval: 1000
|
||||
repeat: true
|
||||
onTriggered: root.player.positionChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue