SidePanel: proper height computation

This commit is contained in:
LemmyCook 2025-09-07 00:49:59 -04:00
parent 9010a1668b
commit adac96ee84

View file

@ -11,71 +11,92 @@ NPanel {
id: root id: root
panelWidth: 460 * scaling panelWidth: 460 * scaling
panelHeight: 708 * scaling panelHeight: contentHeight
// Default height, will be modified via binding when the content is fully loaded
property real contentHeight: 720 * scaling
panelContent: Item { panelContent: Item {
id: content id: content
property real cardSpacing: Style.marginL * scaling property real cardSpacing: Style.marginL * scaling
anchors.left: parent.left width: root.panelWidth
anchors.right: parent.right implicitHeight: layout.implicitHeight + (2 * cardSpacing)
anchors.top: parent.top height: implicitHeight
anchors.margins: content.cardSpacing
implicitHeight: layout.implicitHeight
// Layout content (not vertically anchored so implicitHeight is valid) // Update parent's contentHeight whenever our height changes
onHeightChanged: {
root.contentHeight = height
}
onImplicitHeightChanged: {
if (implicitHeight > 0) {
root.contentHeight = implicitHeight
}
}
// Layout content
ColumnLayout { ColumnLayout {
id: layout id: layout
// Use the same spacing value horizontally and vertically x: content.cardSpacing
anchors.left: parent.left y: content.cardSpacing
anchors.right: parent.right width: parent.width - (2 * content.cardSpacing)
anchors.top: parent.top
spacing: content.cardSpacing spacing: content.cardSpacing
// Cards (consistent inter-card spacing via ColumnLayout spacing) // Cards (consistent inter-card spacing via ColumnLayout spacing)
ProfileCard {// Layout.topMargin: 0 ProfileCard {
// Layout.bottomMargin: 0 id: profileCard
Layout.fillWidth: true
} }
WeatherCard {// Layout.topMargin: 0
// Layout.bottomMargin: 0 WeatherCard {
id: weatherCard
Layout.fillWidth: true
} }
// Middle section: media + stats column // Middle section: media + stats column
RowLayout { RowLayout {
id: middleRow
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 0 Layout.minimumHeight: 280 * scaling
Layout.bottomMargin: 0 Layout.preferredHeight: Math.max(280 * scaling, statsCard.implicitHeight)
spacing: content.cardSpacing spacing: content.cardSpacing
// Media card // Media card
MediaCard { MediaCard {
id: mediaCard id: mediaCard
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: statsCard.implicitHeight Layout.fillHeight: true
} }
// System monitors combined in one card // System monitors combined in one card
SystemMonitorCard { SystemMonitorCard {
id: statsCard id: statsCard
Layout.alignment: Qt.AlignTop
} }
} }
// Bottom actions (two grouped rows of round buttons) // Bottom actions (two grouped rows of round buttons)
RowLayout { RowLayout {
id: bottomRow
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 0 Layout.minimumHeight: 60 * scaling
Layout.bottomMargin: 0 Layout.preferredHeight: Math.max(60 * scaling, powerProfilesCard.implicitHeight, utilitiesCard.implicitHeight)
spacing: content.cardSpacing spacing: content.cardSpacing
// Power Profiles switcher // Power Profiles switcher
PowerProfilesCard { PowerProfilesCard {
id: powerProfilesCard
spacing: content.cardSpacing spacing: content.cardSpacing
Layout.fillWidth: true
} }
// Utilities buttons // Utilities buttons
UtilitiesCard { UtilitiesCard {
id: utilitiesCard
spacing: content.cardSpacing spacing: content.cardSpacing
Layout.fillWidth: true
} }
} }
} }