This commit is contained in:
Benjamin Palko 2025-08-27 23:21:48 -04:00
parent d42b7cb612
commit 9757567855
2 changed files with 70 additions and 73 deletions

View file

@ -9,88 +9,82 @@ import QtQuick.Layouts
import Quickshell.Services.Mpris
import Quickshell.Widgets
WrapperRectangle {
ColumnLayout {
id: root
required property MprisPlayer player
color: Theme.palette.base200
radius: 8
margin: 16
spacing: 12
ColumnLayout {
implicitWidth: 800
spacing: 12
StyledText {
id: text
Layout.alignment: Qt.AlignHCenter
text: `${root.player.trackTitle} - ${root.player.trackArtist}`
font.pixelSize: Dimensions.mpris.fontSize
}
implicitWidth: 800
StyledText {
id: text
Layout.alignment: Qt.AlignHCenter
text: `${root.player.trackTitle} - ${root.player.trackArtist}`
font.pixelSize: Dimensions.mpris.fontSize
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
StyledButton {
id: backButton
content: LucideIcon {
color: backButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: Icons.skipBack
}
onClicked: {
root.player.previous();
}
RowLayout {
Layout.alignment: Qt.AlignHCenter
StyledButton {
id: backButton
content: LucideIcon {
color: backButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: Icons.skipBack
}
StyledButton {
id: playPauseButton
content: LucideIcon {
color: playPauseButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: root.player.isPlaying ? Icons.square : Icons.play
}
onClicked: {
root.player.isPlaying = !root.player.isPlaying;
}
}
StyledButton {
id: forwardButton
content: LucideIcon {
color: forwardButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: Icons.skipForward
}
onClicked: {
root.player.next();
}
onClicked: {
root.player.previous();
}
}
StyledText {
Layout.alignment: Qt.AlignHCenter
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)}`;
StyledButton {
id: playPauseButton
content: LucideIcon {
color: playPauseButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: root.player.isPlaying ? Icons.square : Icons.play
}
onClicked: {
root.player.isPlaying = !root.player.isPlaying;
}
font.pixelSize: Dimensions.mpris.fontSize
}
StyledSlider {
from: 0
to: root.player.length ?? 0
value: root.player.position
implicitHeight: 6
Layout.fillWidth: true
onMoved: {
root.player.position = value;
StyledButton {
id: forwardButton
content: LucideIcon {
color: forwardButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: Icons.skipForward
}
Timer {
running: root.player.isPlaying
interval: 1000
repeat: true
onTriggered: root.player.positionChanged()
onClicked: {
root.player.next();
}
}
}
StyledText {
Layout.alignment: Qt.AlignHCenter
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)}`;
}
font.pixelSize: Dimensions.mpris.fontSize
}
StyledSlider {
from: 0
to: root.player.length ?? 0
value: root.player.position
implicitHeight: 6
Layout.fillWidth: true
onMoved: {
root.player.position = value;
}
Timer {
running: root.player.isPlaying
interval: 1000
repeat: true
onTriggered: root.player.positionChanged()
}
}
}

View file

@ -15,11 +15,14 @@ StyledDrawer {
visible: Visibility.dashboard
WrapperRectangle {
color: Theme.palette.base300
color: Theme.palette.base200
radius: 8
margin: 20
margin: 32
ColumnLayout {
RowLayout {
spacing: 8
RowLayout {
spacing: 8
Layout.alignment: Qt.AlignHCenter
StyledButton {
@ -60,7 +63,7 @@ StyledDrawer {
}
MprisController {
player: Mpris.active
player: Mpris.active
}
}
}