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 "../bar" as Bar MouseArea { 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 implicitHeight: mediaCircProg.implicitHeight implicitWidth: Appearance.sizes.verticalBarWidth Timer { running: activePlayer?.playbackState == MprisPlaybackState.Playing interval: Config.options.resources.updateInterval repeat: true onTriggered: activePlayer.positionChanged() } acceptedButtons: Qt.MiddleButton | Qt.BackButton | Qt.ForwardButton | Qt.RightButton | Qt.LeftButton hoverEnabled: true 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) { GlobalStates.mediaControlsOpen = !GlobalStates.mediaControlsOpen } } ClippedFilledCircularProgress { id: mediaCircProg anchors.centerIn: parent implicitSize: 20 lineWidth: Appearance.rounding.unsharpen value: activePlayer?.position / activePlayer?.length colPrimary: Appearance.colors.colOnSecondaryContainer enableAnimation: false Item { anchors.centerIn: parent width: mediaCircProg.implicitSize height: mediaCircProg.implicitSize MaterialSymbol { anchors.centerIn: parent fill: 1 text: activePlayer?.isPlaying ? "pause" : "music_note" iconSize: Appearance.font.pixelSize.normal color: Appearance.m3colors.m3onSecondaryContainer } } } Bar.StyledPopup { hoverTarget: root active: GlobalStates.mediaControlsOpen ? false : root.containsMouse Column { anchors.centerIn: parent spacing: 4 Row { spacing: 4 MaterialSymbol { anchors.verticalCenter: parent.verticalCenter fill: 0 font.weight: Font.Medium text: "music_note" iconSize: Appearance.font.pixelSize.large color: Appearance.colors.colOnSurfaceVariant } StyledText { anchors.verticalCenter: parent.verticalCenter text: "Media" font { weight: Font.Medium pixelSize: Appearance.font.pixelSize.normal } color: Appearance.colors.colOnSurfaceVariant } } StyledText { text: `${cleanedTitle}${activePlayer?.trackArtist ? '\n' + activePlayer.trackArtist : ''}` } } } }