From ab4359b6248651cdafd3a474769809530a7386f4 Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Sun, 31 Aug 2025 09:15:16 -0400 Subject: [PATCH] ActiveWindo/MediaMini: slight width improvements --- Modules/Bar/Widgets/ActiveWindow.qml | 20 +++++++++++--------- Modules/Bar/Widgets/MediaMini.qml | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index 4c5565f..19a1f0a 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -12,17 +12,14 @@ Row { property ShellScreen screen property real scaling: ScalingService.scale(screen) - // Title stays collapsed by default; expands only on hover - property bool showingFullTitle: false - readonly property int minWidth: 120 + readonly property real minWidth: 160 + readonly property real maxWidth: 400 anchors.verticalCenter: parent.verticalCenter spacing: Style.marginS * scaling visible: getTitle() !== "" - // Remove auto-expand timer; we rely solely on hover - // No auto-expansion on window change; keep collapsed unless hovered function getTitle() { // Use the service's focusedWindowTitle property which is updated immediately // when WindowOpenedOrChanged events are received @@ -49,7 +46,7 @@ Row { Rectangle { // Let the Rectangle size itself based on its content (the Row) visible: root.visible - width: row.width + Style.marginS * scaling + width: row.width + Style.marginM * 2 * scaling height: Math.round(Style.capsuleHeight * scaling) radius: Math.round(Style.radiusM * scaling) color: Color.mSurfaceVariant @@ -89,9 +86,14 @@ Row { id: titleText // For short titles, show full. For long titles, truncate and expand on hover - width: mouseArea.containsMouse ? Math.min(fullTitleMetrics.contentWidth + 8, - 400 * scaling) : Math.min(fullTitleMetrics.contentWidth + 12, - 200 * scaling) + width: { + if (mouseArea.containsMouse) { + return Math.round(Math.min(fullTitleMetrics.contentWidth, root.maxWidth * scaling)) + } + else { + return Math.round(Math.min(fullTitleMetrics.contentWidth, root.minWidth * scaling)) + } + } horizontalAlignment: Text.AlignLeft text: getTitle() font.pointSize: Style.fontSizeS * scaling diff --git a/Modules/Bar/Widgets/MediaMini.qml b/Modules/Bar/Widgets/MediaMini.qml index 5607fe2..7ae85be 100644 --- a/Modules/Bar/Widgets/MediaMini.qml +++ b/Modules/Bar/Widgets/MediaMini.qml @@ -12,6 +12,8 @@ Row { property ShellScreen screen property real scaling: ScalingService.scale(screen) + readonly property real minWidth: 160 + readonly property real maxWidth: 400 anchors.verticalCenter: parent.verticalCenter spacing: Style.marginS * scaling @@ -34,7 +36,7 @@ Row { id: mediaMini // Let the Rectangle size itself based on its content (the Row) - width: row.width + Style.marginM * scaling * 2 + width: row.width + Style.marginM * 2 * scaling height: Math.round(Style.capsuleHeight * scaling) radius: Math.round(Style.radiusM * scaling) @@ -140,11 +142,15 @@ Row { NText { id: titleText - // If hovered or just switched window, show up to 400 pixels - // If not hovered show up to 120 pixels - width: (mouseArea.containsMouse) ? Math.min(fullTitleMetrics.contentWidth, - 400 * scaling) : Math.min(fullTitleMetrics.contentWidth, - 120 * scaling) + // For short titles, show full. For long titles, truncate and expand on hover + width: { + if (mouseArea.containsMouse) { + return Math.round(Math.min(fullTitleMetrics.contentWidth, root.maxWidth * scaling)) + } + else { + return Math.round(Math.min(fullTitleMetrics.contentWidth, root.minWidth * scaling)) + } + } text: getTitle() font.pointSize: Style.fontSizeS * scaling font.weight: Style.fontWeightMedium