ActiveWindo/MediaMini: slight width improvements

This commit is contained in:
LemmyCook 2025-08-31 09:15:16 -04:00
parent 68a44b6ef7
commit ab4359b624
2 changed files with 23 additions and 15 deletions

View file

@ -12,17 +12,14 @@ Row {
property ShellScreen screen property ShellScreen screen
property real scaling: ScalingService.scale(screen) property real scaling: ScalingService.scale(screen)
// Title stays collapsed by default; expands only on hover readonly property real minWidth: 160
property bool showingFullTitle: false readonly property real maxWidth: 400
readonly property int minWidth: 120
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: Style.marginS * scaling spacing: Style.marginS * scaling
visible: getTitle() !== "" visible: getTitle() !== ""
// Remove auto-expand timer; we rely solely on hover
// No auto-expansion on window change; keep collapsed unless hovered
function getTitle() { function getTitle() {
// Use the service's focusedWindowTitle property which is updated immediately // Use the service's focusedWindowTitle property which is updated immediately
// when WindowOpenedOrChanged events are received // when WindowOpenedOrChanged events are received
@ -49,7 +46,7 @@ Row {
Rectangle { Rectangle {
// Let the Rectangle size itself based on its content (the Row) // Let the Rectangle size itself based on its content (the Row)
visible: root.visible visible: root.visible
width: row.width + Style.marginS * scaling width: row.width + Style.marginM * 2 * scaling
height: Math.round(Style.capsuleHeight * scaling) height: Math.round(Style.capsuleHeight * scaling)
radius: Math.round(Style.radiusM * scaling) radius: Math.round(Style.radiusM * scaling)
color: Color.mSurfaceVariant color: Color.mSurfaceVariant
@ -89,9 +86,14 @@ Row {
id: titleText id: titleText
// For short titles, show full. For long titles, truncate and expand on hover // For short titles, show full. For long titles, truncate and expand on hover
width: mouseArea.containsMouse ? Math.min(fullTitleMetrics.contentWidth + 8, width: {
400 * scaling) : Math.min(fullTitleMetrics.contentWidth + 12, if (mouseArea.containsMouse) {
200 * scaling) return Math.round(Math.min(fullTitleMetrics.contentWidth, root.maxWidth * scaling))
}
else {
return Math.round(Math.min(fullTitleMetrics.contentWidth, root.minWidth * scaling))
}
}
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
text: getTitle() text: getTitle()
font.pointSize: Style.fontSizeS * scaling font.pointSize: Style.fontSizeS * scaling

View file

@ -12,6 +12,8 @@ Row {
property ShellScreen screen property ShellScreen screen
property real scaling: ScalingService.scale(screen) property real scaling: ScalingService.scale(screen)
readonly property real minWidth: 160
readonly property real maxWidth: 400
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: Style.marginS * scaling spacing: Style.marginS * scaling
@ -34,7 +36,7 @@ Row {
id: mediaMini id: mediaMini
// Let the Rectangle size itself based on its content (the Row) // 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) height: Math.round(Style.capsuleHeight * scaling)
radius: Math.round(Style.radiusM * scaling) radius: Math.round(Style.radiusM * scaling)
@ -140,11 +142,15 @@ Row {
NText { NText {
id: titleText id: titleText
// If hovered or just switched window, show up to 400 pixels // For short titles, show full. For long titles, truncate and expand on hover
// If not hovered show up to 120 pixels width: {
width: (mouseArea.containsMouse) ? Math.min(fullTitleMetrics.contentWidth, if (mouseArea.containsMouse) {
400 * scaling) : Math.min(fullTitleMetrics.contentWidth, return Math.round(Math.min(fullTitleMetrics.contentWidth, root.maxWidth * scaling))
120 * scaling) }
else {
return Math.round(Math.min(fullTitleMetrics.contentWidth, root.minWidth * scaling))
}
}
text: getTitle() text: getTitle()
font.pointSize: Style.fontSizeS * scaling font.pointSize: Style.fontSizeS * scaling
font.weight: Style.fontWeightMedium font.weight: Style.fontWeightMedium