diff --git a/components/MprisController.qml b/components/MprisController.qml index 2873909..fd41afe 100644 --- a/components/MprisController.qml +++ b/components/MprisController.qml @@ -23,19 +23,6 @@ WrapperRectangle { implicitWidth: 800 - StyledText { - Layout.alignment: Qt.AlignHCenter - text: { - if (root.player.identity) { - const words = root.player.identity.split("-"); - const capitalized = words.map(val => String(val).charAt(0).toUpperCase() + String(val).slice(1)); - return capitalized.join(" "); - } - return root.player.desktopEntry ?? root.player.dbusName ?? "unknown"; - } - font.pixelSize: 20 - } - StyledText { id: text Layout.alignment: Qt.AlignHCenter @@ -77,6 +64,17 @@ WrapperRectangle { } } + 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 diff --git a/components/StyledDrawer.qml b/components/StyledDrawer.qml index aae1b15..c153482 100644 --- a/components/StyledDrawer.qml +++ b/components/StyledDrawer.qml @@ -8,8 +8,7 @@ Drawer { background: Rectangle { Component.onCompleted: { if (control.edge == Qt.TopEdge) { - bottomLeftRadius = 8; - bottomRightRadius = 8; + radius = 8; } else if (control.edge == Qt.LeftEdge) { topRightRadius = 8; bottomRightRadius = 8; diff --git a/services/Mpris.qml b/services/Mpris.qml index 54648ae..b6ebadc 100644 --- a/services/Mpris.qml +++ b/services/Mpris.qml @@ -8,5 +8,25 @@ Singleton { id: root property list players: Mpris.players.values - property MprisPlayer active: players.filter(player => player.isPlaying)[0] ?? players[0] + property MprisPlayer active: players[properties.currentIndex] + + PersistentProperties { + id: properties + + property int currentIndex: 0 + } + + function nextPlayer() { + if (players.length == 0) { + return; + } + properties.currentIndex = properties.currentIndex + 1 % players.length; + } + + function previousPlayer() { + if (players.length == 0) { + return; + } + properties.currentIndex = properties.currentIndex - 1 % players.length; + } }