import qs.modules.common import qs.modules.common.widgets import qs.services import qs import qs.modules.common.functions import QtQuick import QtQuick.Layouts import Quickshell.Services.Mpris import Quickshell.Hyprland Item { id: root property bool borderless: Config.options.bar.borderless readonly property MprisPlayer activePlayer: MprisController.activePlayer readonly property string cleanedTitle: StringUtils.cleanMusicTitle(activePlayer?.trackTitle) || Translation.tr("No media") Layout.fillHeight: true implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 2 implicitHeight: Appearance.sizes.barHeight Timer { running: activePlayer?.playbackState == MprisPlaybackState.Playing interval: 1000 repeat: true onTriggered: activePlayer.positionChanged() } MouseArea { anchors.fill: parent acceptedButtons: Qt.MiddleButton | Qt.BackButton | Qt.ForwardButton | Qt.RightButton | Qt.LeftButton onPressed: (event) => { if (event.button === Qt.MiddleButton) { activePlayer.togglePlaying(); } else if (event.button === Qt.BackButton) { activePlayer.previous(); } else if (event.button === Qt.ForwardButton || event.button === Qt.RightButton) { activePlayer.next(); } else if (event.button === Qt.LeftButton) { Hyprland.dispatch("global quickshell:mediaControlsToggle") } } } RowLayout { // Real content id: rowLayout spacing: 4 anchors.fill: parent CircularProgress { Layout.alignment: Qt.AlignVCenter Layout.leftMargin: rowLayout.spacing lineWidth: 2 value: activePlayer?.position / activePlayer?.length size: 26 secondaryColor: Appearance.colors.colSecondaryContainer primaryColor: Appearance.m3colors.m3onSecondaryContainer enableAnimation: false MaterialSymbol { anchors.centerIn: parent fill: 1 text: activePlayer?.isPlaying ? "pause" : "music_note" 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.AlignVCenter Layout.fillWidth: true // Ensures the text takes up available space Layout.rightMargin: rowLayout.spacing horizontalAlignment: Text.AlignHCenter elide: Text.ElideRight // Truncates the text on the right color: Appearance.colors.colOnLayer1 text: `${cleanedTitle}${activePlayer?.trackArtist ? ' • ' + activePlayer.trackArtist : ''}` } } }