From 1efa1f4aa3658b35e71b79b5d5b1ec0db226add2 Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Fri, 5 Sep 2025 19:06:15 -0400 Subject: [PATCH] ActiveWindow: Converted to Layout --- Modules/Bar/Widgets/ActiveWindow.qml | 33 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index c7387d1..3a7dd36 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -7,7 +7,7 @@ import qs.Commons import qs.Services import qs.Widgets -Row { +RowLayout { id: root property ShellScreen screen @@ -15,7 +15,7 @@ Row { readonly property real minWidth: 160 readonly property real maxWidth: 400 - anchors.verticalCenter: parent.verticalCenter + Layout.alignment: Qt.AlignVCenter spacing: Style.marginS * scaling visible: getTitle() !== "" @@ -33,7 +33,7 @@ Row { return Icons.iconForAppId(focusedWindow.appId) } - // A hidden text element to safely measure the full title width + // A hidden text element to safely measure the full title width NText { id: fullTitleMetrics visible: false @@ -43,15 +43,13 @@ Row { } Rectangle { - // Let the Rectangle size itself based on its content (the Row) + id: windowTitleRect visible: root.visible - width: row.width + Style.marginM * 2 * scaling - height: Math.round(Style.capsuleHeight * scaling) + Layout.preferredWidth: contentLayout.implicitWidth + Style.marginM * 2 * scaling + Layout.preferredHeight: Math.round(Style.capsuleHeight * scaling) radius: Math.round(Style.radiusM * scaling) color: Color.mSurfaceVariant - anchors.verticalCenter: parent.verticalCenter - Item { id: mainContainer anchors.fill: parent @@ -59,16 +57,16 @@ Row { anchors.rightMargin: Style.marginS * scaling clip: true - Row { - id: row - anchors.verticalCenter: parent.verticalCenter + RowLayout { + id: contentLayout + anchors.centerIn: parent spacing: Style.marginS * scaling // Window icon Item { - width: Style.fontSizeL * scaling * 1.2 - height: Style.fontSizeL * scaling * 1.2 - anchors.verticalCenter: parent.verticalCenter + Layout.preferredWidth: Style.fontSizeL * scaling * 1.2 + Layout.preferredHeight: Style.fontSizeL * scaling * 1.2 + Layout.alignment: Qt.AlignVCenter visible: getTitle() !== "" && Settings.data.bar.showActiveWindowIcon IconImage { @@ -85,24 +83,25 @@ Row { id: titleText // For short titles, show full. For long titles, truncate and expand on hover - width: { + Layout.preferredWidth: { if (mouseArea.containsMouse) { return Math.round(Math.min(fullTitleMetrics.contentWidth, root.maxWidth * scaling)) } else { return Math.round(Math.min(fullTitleMetrics.contentWidth, root.minWidth * scaling)) } } + Layout.alignment: Qt.AlignVCenter + horizontalAlignment: Text.AlignLeft text: getTitle() font.pointSize: Style.fontSizeS * scaling font.weight: Style.fontWeightMedium elide: mouseArea.containsMouse ? Text.ElideNone : Text.ElideRight - anchors.verticalCenter: parent.verticalCenter verticalAlignment: Text.AlignVCenter color: Color.mSecondary clip: true - Behavior on width { + Behavior on Layout.preferredWidth { NumberAnimation { duration: Style.animationSlow easing.type: Easing.InOutCubic