SetupWizard: positionning fix

This commit is contained in:
ItsLemmy
2025-11-07 08:42:07 -05:00
parent 8d1047cc62
commit 5fa8cabbe1
2 changed files with 17 additions and 8 deletions
+13 -4
View File
@@ -176,6 +176,15 @@ Item {
} }
function setPosition() { function setPosition() {
// Don't calculate position if parent dimensions aren't available yet
// This prevents centering around (0,0) when width/height are still 0
if (!root.width || !root.height) {
Logger.d("SmartPanel", "Skipping setPosition - dimensions not ready:", root.width, "x", root.height)
// Retry on next frame when dimensions should be available
Qt.callLater(setPosition)
return
}
// Calculate panel dimensions first (needed for positioning) // Calculate panel dimensions first (needed for positioning)
var w var w
// Priority 1: Content-driven size (dynamic) // Priority 1: Content-driven size (dynamic)
@@ -183,12 +192,12 @@ Item {
w = contentLoader.item.contentPreferredWidth w = contentLoader.item.contentPreferredWidth
} // Priority 2: Ratio-based size } // Priority 2: Ratio-based size
else if (root.preferredWidthRatio !== undefined) { else if (root.preferredWidthRatio !== undefined) {
w = Math.round(Math.max((root.width || 1920) * root.preferredWidthRatio, root.preferredWidth)) w = Math.round(Math.max(root.width * root.preferredWidthRatio, root.preferredWidth))
} // Priority 3: Static preferred width } // Priority 3: Static preferred width
else { else {
w = root.preferredWidth w = root.preferredWidth
} }
var panelWidth = Math.min(w, (root.width || 1920) - Style.marginL * 2) var panelWidth = Math.min(w, root.width - Style.marginL * 2)
var h var h
// Priority 1: Content-driven size (dynamic) // Priority 1: Content-driven size (dynamic)
@@ -196,12 +205,12 @@ Item {
h = contentLoader.item.contentPreferredHeight h = contentLoader.item.contentPreferredHeight
} // Priority 2: Ratio-based size } // Priority 2: Ratio-based size
else if (root.preferredHeightRatio !== undefined) { else if (root.preferredHeightRatio !== undefined) {
h = Math.round(Math.max((root.height || 1080) * root.preferredHeightRatio, root.preferredHeight)) h = Math.round(Math.max(root.height * root.preferredHeightRatio, root.preferredHeight))
} // Priority 3: Static preferred height } // Priority 3: Static preferred height
else { else {
h = root.preferredHeight h = root.preferredHeight
} }
var panelHeight = Math.min(h, (root.height || 1080) - Style.barHeight - Style.marginL * 2) var panelHeight = Math.min(h, root.height - Style.barHeight - Style.marginL * 2)
// Update panelBackground target size (will be animated) // Update panelBackground target size (will be animated)
panelBackground.targetWidth = panelWidth panelBackground.targetWidth = panelWidth
+4 -4
View File
@@ -11,8 +11,8 @@ import qs.Modules.MainScreen
SmartPanel { SmartPanel {
id: root id: root
preferredWidth: 520 * Style.uiScaleRatio preferredWidth: Math.round(520 * Style.uiScaleRatio)
preferredHeight: 600 * Style.uiScaleRatio preferredHeight: Math.round(600 * Style.uiScaleRatio)
preferredWidthRatio: 0.4 preferredWidthRatio: 0.4
preferredHeightRatio: 0.6 preferredHeightRatio: 0.6
@@ -47,7 +47,7 @@ SmartPanel {
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.minimumHeight: 300 Layout.minimumHeight: Math.round(300 * Style.uiScaleRatio)
StackLayout { StackLayout {
id: stepStack id: stepStack
@@ -58,7 +58,7 @@ SmartPanel {
Item { Item {
ColumnLayout { ColumnLayout {
anchors.centerIn: parent anchors.centerIn: parent
width: Math.min(parent.width - Style.marginXL * 2, 420) width: Math.round(Math.min(parent.width - Style.marginXL * 2, 420))
spacing: Style.marginXL spacing: Style.marginXL
// Logo with subtle glow effect // Logo with subtle glow effect