ActiveWindow: Converted to Layout

This commit is contained in:
LemmyCook 2025-09-05 19:06:15 -04:00
parent 0a48e5f34f
commit 1efa1f4aa3

View file

@ -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