import QtQuick import QtQuick.Layouts import Quickshell.Hyprland import Quickshell.Services.Mpris import qs import qs.common import qs.common.widgets Item { id: root property bool borderless: Config.options.bar.borderless Layout.fillHeight: true implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 2 implicitHeight: Appearance.sizes.barHeight Timer { running: MprisController.hasPlayers && MprisController.activePlayer().isPlaying && MprisController.activePlayer().lengthSupported interval: 1000 repeat: true onTriggered: MprisController.activePlayer().positionChanged() } MouseArea { anchors.fill: parent acceptedButtons: Qt.MiddleButton | Qt.BackButton | Qt.ForwardButton | Qt.RightButton | Qt.LeftButton onPressed: (event) => { if (event.button === Qt.MiddleButton) { MprisController.activePlayer().togglePlaying(); } else if (event.button === Qt.BackButton) { MprisController.shiftPlayer(-1); } else if (event.button === Qt.ForwardButton) { MprisController.shiftPlayer(1); } else if (event.button === Qt.LeftButton) { GlobalStates.mediaControlsOpen = !GlobalStates.mediaControlsOpen } } } RowLayout { id: rowLayout spacing: 4 anchors.fill: parent visible: MprisController.hasPlayers CircularProgress { id: circularProgress visible: MprisController.hasPlayers && MprisController.activePlayer().lengthSupported Layout.alignment: Qt.AlignVCenter Layout.leftMargin: rowLayout.spacing lineWidth: 2 value: MprisController.activePlayer().lengthSupported ? MprisController.activePlayer()?.position / MprisController.activePlayer()?.length : 0 implicitSize: 26 colSecondary: Appearance.colors.colSecondaryContainer colPrimary: Appearance.m3colors.m3onSecondaryContainer enableAnimation: false MaterialSymbol { visible: MprisController.hasPlayers && MprisController.activePlayer().lengthSupported anchors.centerIn: parent fill: 1 text: MprisController.activePlayer()?.isPlaying ? "music_note" : "pause" iconSize: Appearance.font.pixelSize.normal color: Appearance.m3colors.m3onSecondaryContainer } } StyledText { visible: Config.options.bar.verbose width: rowLayout.width - (circularProgress.size + rowLayout.spacing * 2) Layout.alignment: Qt.AlignCenter Layout.fillWidth: true Layout.rightMargin: rowLayout.spacing horizontalAlignment: Text.AlignHCenter elide: Text.ElideRight color: Appearance.colors.colOnLayer1 text: `${MprisController.activePlayer()?.trackTitle}${MprisController.activePlayer()?.trackArtist ? ' • ' + MprisController.activePlayer().trackArtist : ''}` } } }