MediaMini rebuilt to behave the same as activewindow

This commit is contained in:
quadbyte 2025-08-16 23:29:25 -04:00
parent 2b1893f8bc
commit e3ea79073d
2 changed files with 78 additions and 39 deletions

View file

@ -10,7 +10,7 @@ Row {
id: root id: root
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: Style.marginSmall * scaling spacing: Style.marginSmall * scaling
visible: Settings.data.bar.showActiveWindow visible: (Settings.data.bar.showActiveWindow && getTitle() !== "")
property bool showingFullTitle: false property bool showingFullTitle: false
property int lastWindowIndex: -1 property int lastWindowIndex: -1
@ -94,7 +94,8 @@ Row {
// If hovered or just switched window, show up to 300 pixels // If hovered or just switched window, show up to 300 pixels
// If not hovered show up to 150 pixels // If not hovered show up to 150 pixels
width: (showingFullTitle || mouseArea.containsMouse) ? Math.min(fullTitleMetrics.contentWidth, 300 * scaling) : Math.min( width: (showingFullTitle || mouseArea.containsMouse) ? Math.min(fullTitleMetrics.contentWidth,
300 * scaling) : Math.min(
fullTitleMetrics.contentWidth, 150 * scaling) fullTitleMetrics.contentWidth, 150 * scaling)
text: getTitle() text: getTitle()
font.pointSize: Style.fontSizeReduced * scaling font.pointSize: Style.fontSizeReduced * scaling
@ -102,7 +103,7 @@ Row {
elide: Text.ElideRight elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: Color.mTertiary color: Color.mSecondary
Behavior on width { Behavior on width {
NumberAnimation { NumberAnimation {

View file

@ -1,54 +1,92 @@
import QtQuick import QtQuick
import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell
import qs.Commons import qs.Commons
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
Item { Row {
id: root id: root
anchors.verticalCenter: parent.verticalCenter
width: visible ? mediaRow.width : 0 spacing: Style.marginSmall * scaling
height: Style.barHeight * scaling
visible: Settings.data.bar.showMedia && (MediaService.canPlay || MediaService.canPause) visible: Settings.data.bar.showMedia && (MediaService.canPlay || MediaService.canPause)
RowLayout { function getTitle() {
id: mediaRow return MediaService.trackTitle + (MediaService.trackArtist !== "" ? ` - ${MediaService.trackArtist}` : "")
height: parent.height }
spacing: Style.spacingTiniest * scaling
// NIconButton { // A hidden text element to safely measure the full title width
// icon: MediaService.isPlaying ? "pause" : "play_arrow" NText {
// tooltipText: "Play/pause media" id: fullTitleMetrics
// sizeMultiplier: 0.8 visible: false
// showBorder: false text: titleText.text
// onClicked: MediaService.playPause() font: titleText.font
// } }
NText {
text: MediaService.isPlaying ? "pause" : "play_arrow"
font.family: "Material Symbols Outlined"
font.pointSize: Style.fontSizeLarge * scaling
verticalAlignment: Text.AlignVCenter
MouseArea { Rectangle {
id: titleContainerMouseArea // Let the Rectangle size itself based on its content (the Row)
anchors.fill: parent width: row.width + Style.marginMedium * scaling * 2
height: row.height + Style.marginSmall * scaling
color: Color.mSurfaceVariant
radius: Style.radiusSmall * scaling
anchors.verticalCenter: parent.verticalCenter
onClicked: { Item {
onClicked: MediaService.playPause() id: mainContainer
anchors.fill: parent
anchors.leftMargin: Style.marginSmall * scaling
anchors.rightMargin: Style.marginSmall * scaling
Row {
id: row
anchors.verticalCenter: parent.verticalCenter
spacing: Style.marginTiny * scaling
// Window icon
NText {
id: windowIcon
text: MediaService.isPlaying ? "pause" : "play_arrow"
font.family: "Material Symbols Outlined"
font.pointSize: Style.fontSizeLarge * scaling
verticalAlignment: Text.AlignVCenter
anchors.verticalCenter: parent.verticalCenter
visible: getTitle() !== ""
}
NText {
id: titleText
// If hovered or just switched window, show up to 300 pixels
// If not hovered show up to 150 pixels
width: (mouseArea.containsMouse) ? Math.min(fullTitleMetrics.contentWidth,
400 * scaling) : Math.min(
fullTitleMetrics.contentWidth, 150 * scaling)
text: getTitle()
font.pointSize: Style.fontSizeReduced * scaling
font.weight: Style.fontWeightBold
elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
color: Color.mSecondary
Behavior on width {
NumberAnimation {
duration: Style.animationSlow
easing.type: Easing.InOutCubic
}
}
} }
} }
}
// Track info // Mouse area for hover detection
NText { MouseArea {
text: MediaService.trackTitle + (MediaService.trackArtist !== "" ? ` - {MediaService.trackArtist}` : "") id: mouseArea
font.pointSize: Style.fontSizeReduced * scaling anchors.fill: parent
font.weight: Style.fontWeightBold hoverEnabled: true
elide: Text.ElideRight cursorShape: Qt.PointingHandCursor
color: Color.mSecondary onClicked: MediaService.playPause()
verticalAlignment: Text.AlignVCenter }
Layout.maximumWidth: 200 * scaling
Layout.alignment: Qt.AlignVCenter
} }
} }
} }