Fix spacing for vertical bar

This commit is contained in:
Ly-sec 2025-09-13 15:51:21 +02:00
parent e706dabef3
commit ee50d84a53
5 changed files with 28 additions and 36 deletions

View file

@ -171,14 +171,13 @@ Variants {
Component { Component {
id: horizontalBarComponent id: horizontalBarComponent
Row { Item {
anchors.fill: parent anchors.fill: parent
// Left Section // Left Section
Row { RowLayout {
id: leftSection id: leftSection
objectName: "leftSection" objectName: "leftSection"
height: parent.height
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: Style.marginS * root.scaling anchors.leftMargin: Style.marginS * root.scaling
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -197,16 +196,14 @@ Variants {
"sectionWidgetsCount": Settings.data.bar.widgets.left.length, "sectionWidgetsCount": Settings.data.bar.widgets.left.length,
"barPosition": BarService.position "barPosition": BarService.position
} }
anchors.verticalCenter: parent.verticalCenter
} }
} }
} }
// Center Section // Center Section
Row { RowLayout {
id: centerSection id: centerSection
objectName: "centerSection" objectName: "centerSection"
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: Style.marginS * root.scaling spacing: Style.marginS * root.scaling
@ -224,16 +221,14 @@ Variants {
"sectionWidgetsCount": Settings.data.bar.widgets.center.length, "sectionWidgetsCount": Settings.data.bar.widgets.center.length,
"barPosition": BarService.position "barPosition": BarService.position
} }
anchors.verticalCenter: parent.verticalCenter
} }
} }
} }
// Right Section // Right Section
Row { RowLayout {
id: rightSection id: rightSection
objectName: "rightSection" objectName: "rightSection"
height: parent.height
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Style.marginS * root.scaling anchors.rightMargin: Style.marginS * root.scaling
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -252,7 +247,6 @@ Variants {
"sectionWidgetsCount": Settings.data.bar.widgets.right.length, "sectionWidgetsCount": Settings.data.bar.widgets.right.length,
"barPosition": BarService.position "barPosition": BarService.position
} }
anchors.verticalCenter: parent.verticalCenter
} }
} }
} }

View file

@ -19,17 +19,17 @@ Item {
property int sectionWidgetIndex: -1 property int sectionWidgetIndex: -1
property int sectionWidgetsCount: 0 property int sectionWidgetsCount: 0
property string barPosition: "top" property string barPosition: "top"
// Listen to BarService position changes // Listen to BarService position changes
Connections { Connections {
target: BarService target: BarService
function onBarPositionChanged(newPosition) { function onBarPositionChanged(newPosition) {
barPosition = newPosition barPosition = newPosition
// Force re-evaluation of implicit sizing // Force re-evaluation of implicit sizing
implicitWidth = Qt.binding(function() { implicitWidth = Qt.binding(function () {
return (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : calculatedHorizontalWidth() return (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (horizontalLayout.implicitWidth + Style.marginM * 2 * scaling)
}) })
implicitHeight = Qt.binding(function() { implicitHeight = Qt.binding(function () {
return (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) return (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)
}) })
} }
@ -53,7 +53,7 @@ Item {
readonly property real maxWidth: minWidth * 2 readonly property real maxWidth: minWidth * 2
implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : calculatedHorizontalWidth() implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (horizontalLayout.implicitWidth + Style.marginM * 2 * scaling)
function getTitle() { function getTitle() {
try { try {
@ -97,8 +97,7 @@ Item {
total += titleWidth total += titleWidth
} }
// Row layout handles spacing between widgets // Row layout handles spacing between widgets
return Math.max(total, Style.capsuleHeight * scaling) // Minimum width return Math.max(total, Style.capsuleHeight * scaling) // Minimum width
} }

View file

@ -19,17 +19,17 @@ Item {
property int sectionWidgetIndex: -1 property int sectionWidgetIndex: -1
property int sectionWidgetsCount: 0 property int sectionWidgetsCount: 0
property string barPosition: "top" property string barPosition: "top"
// Listen to BarService position changes // Listen to BarService position changes
Connections { Connections {
target: BarService target: BarService
function onBarPositionChanged(newPosition) { function onBarPositionChanged(newPosition) {
barPosition = newPosition barPosition = newPosition
// Force re-evaluation of implicit sizing // Force re-evaluation of implicit sizing
implicitWidth = Qt.binding(function() { implicitWidth = Qt.binding(function () {
return (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : calculatedHorizontalWidth() return (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (rowLayout.implicitWidth + Style.marginM * 2 * scaling)
}) })
implicitHeight = Qt.binding(function() { implicitHeight = Qt.binding(function () {
return (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) return (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)
}) })
} }
@ -75,7 +75,7 @@ Item {
} }
implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : calculatedHorizontalWidth() implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (rowLayout.implicitWidth + Style.marginM * 2 * scaling)
visible: MediaService.currentPlayer !== null && MediaService.canPlay visible: MediaService.currentPlayer !== null && MediaService.canPlay

View file

@ -17,17 +17,17 @@ Item {
property int sectionWidgetIndex: -1 property int sectionWidgetIndex: -1
property int sectionWidgetsCount: 0 property int sectionWidgetsCount: 0
property string barPosition: "top" property string barPosition: "top"
// Listen to BarService position changes // Listen to BarService position changes
Connections { Connections {
target: BarService target: BarService
function onBarPositionChanged(newPosition) { function onBarPositionChanged(newPosition) {
barPosition = newPosition barPosition = newPosition
// Force re-evaluation of implicit sizing // Force re-evaluation of implicit sizing
implicitWidth = Qt.binding(function() { implicitWidth = Qt.binding(function () {
return (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : calculatedHorizontalWidth() return (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : (horizontalLayout.implicitWidth + Style.marginL * 2 * scaling)
}) })
implicitHeight = Qt.binding(function() { implicitHeight = Qt.binding(function () {
return (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) return (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)
}) })
} }
@ -52,7 +52,7 @@ Item {
readonly property bool showDiskUsage: (widgetSettings.showDiskUsage !== undefined) ? widgetSettings.showDiskUsage : widgetMetadata.showDiskUsage readonly property bool showDiskUsage: (widgetSettings.showDiskUsage !== undefined) ? widgetSettings.showDiskUsage : widgetMetadata.showDiskUsage
implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : calculatedHorizontalWidth() implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : (horizontalLayout.implicitWidth + Style.marginL * 2 * scaling)
function calculatedVerticalHeight() { function calculatedVerticalHeight() {
let total = 0 let total = 0
@ -70,14 +70,14 @@ Item {
visibleCount++ visibleCount++
total = visibleCount * Math.round(Style.capsuleHeight * scaling) total = visibleCount * Math.round(Style.capsuleHeight * scaling)
total += Math.max(visibleCount - 1, 0) * Style.marginS * scaling total += Math.max(visibleCount - 1, 0) * Style.marginXS * scaling
total += Style.marginM * scaling * 2 // padding total += Style.marginM * scaling * 2 // padding
return total return total
} }
function calculatedHorizontalWidth() { function calculatedHorizontalWidth() {
let total = Style.marginM * scaling * 2 // base padding let total = Style.marginL * scaling * 2.5 // base padding
if (showCpuUsage) { if (showCpuUsage) {
// Icon + "99%" text // Icon + "99%" text
@ -136,8 +136,7 @@ Item {
total += (visibleCount - 1) * Style.marginXS * scaling total += (visibleCount - 1) * Style.marginXS * scaling
} }
// Row layout handles spacing between widgets // Row layout handles spacing between widgets
return Math.max(total, Style.capsuleHeight * scaling) return Math.max(total, Style.capsuleHeight * scaling)
} }
@ -145,7 +144,7 @@ Item {
id: backgroundContainer id: backgroundContainer
anchors.left: parent.left anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : calculatedHorizontalWidth() width: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : (horizontalLayout.implicitWidth + Style.marginL * 2 * scaling)
height: (barPosition === "left" || barPosition === "right") ? parent.height : Math.round(Style.capsuleHeight * scaling) height: (barPosition === "left" || barPosition === "right") ? parent.height : Math.round(Style.capsuleHeight * scaling)
radius: Math.round(Style.radiusM * scaling) radius: Math.round(Style.radiusM * scaling)
color: Color.mSurfaceVariant color: Color.mSurfaceVariant
@ -345,7 +344,7 @@ Item {
anchors.centerIn: parent anchors.centerIn: parent
width: Math.round(32 * scaling) width: Math.round(32 * scaling)
height: parent.height - Style.marginM * scaling * 2 height: parent.height - Style.marginM * scaling * 2
spacing: Style.marginS * scaling spacing: Style.marginXS * scaling
visible: barPosition === "left" || barPosition === "right" visible: barPosition === "left" || barPosition === "right"
// CPU Usage Component // CPU Usage Component

View file

@ -20,17 +20,17 @@ Item {
property int sectionWidgetIndex: -1 property int sectionWidgetIndex: -1
property int sectionWidgetsCount: 0 property int sectionWidgetsCount: 0
property string barPosition: "top" property string barPosition: "top"
// Listen to BarService position changes // Listen to BarService position changes
Connections { Connections {
target: BarService target: BarService
function onBarPositionChanged(newPosition) { function onBarPositionChanged(newPosition) {
barPosition = newPosition barPosition = newPosition
// Force re-evaluation of implicit sizing // Force re-evaluation of implicit sizing
implicitWidth = Qt.binding(function() { implicitWidth = Qt.binding(function () {
return (barPosition === "left" || barPosition === "right") ? Math.round(Style.barHeight * scaling) : calculatedHorizontalWidth() return (barPosition === "left" || barPosition === "right") ? Math.round(Style.barHeight * scaling) : calculatedHorizontalWidth()
}) })
implicitHeight = Qt.binding(function() { implicitHeight = Qt.binding(function () {
return (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling) return (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)
}) })
} }