From 5fa8cabbe13e2406def1580d696d239c8d4e26a0 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Fri, 7 Nov 2025 08:42:07 -0500 Subject: [PATCH] SetupWizard: positionning fix --- Modules/MainScreen/SmartPanel.qml | 17 +++++++++++++---- Modules/Panels/SetupWizard/SetupWizard.qml | 8 ++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Modules/MainScreen/SmartPanel.qml b/Modules/MainScreen/SmartPanel.qml index 1afc5d2c..118eaa15 100644 --- a/Modules/MainScreen/SmartPanel.qml +++ b/Modules/MainScreen/SmartPanel.qml @@ -176,6 +176,15 @@ Item { } 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) var w // Priority 1: Content-driven size (dynamic) @@ -183,12 +192,12 @@ Item { w = contentLoader.item.contentPreferredWidth } // Priority 2: Ratio-based size 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 else { 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 // Priority 1: Content-driven size (dynamic) @@ -196,12 +205,12 @@ Item { h = contentLoader.item.contentPreferredHeight } // Priority 2: Ratio-based size 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 else { 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) panelBackground.targetWidth = panelWidth diff --git a/Modules/Panels/SetupWizard/SetupWizard.qml b/Modules/Panels/SetupWizard/SetupWizard.qml index d3cccade..466f618d 100644 --- a/Modules/Panels/SetupWizard/SetupWizard.qml +++ b/Modules/Panels/SetupWizard/SetupWizard.qml @@ -11,8 +11,8 @@ import qs.Modules.MainScreen SmartPanel { id: root - preferredWidth: 520 * Style.uiScaleRatio - preferredHeight: 600 * Style.uiScaleRatio + preferredWidth: Math.round(520 * Style.uiScaleRatio) + preferredHeight: Math.round(600 * Style.uiScaleRatio) preferredWidthRatio: 0.4 preferredHeightRatio: 0.6 @@ -47,7 +47,7 @@ SmartPanel { Item { Layout.fillWidth: true Layout.fillHeight: true - Layout.minimumHeight: 300 + Layout.minimumHeight: Math.round(300 * Style.uiScaleRatio) StackLayout { id: stepStack @@ -58,7 +58,7 @@ SmartPanel { Item { ColumnLayout { 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 // Logo with subtle glow effect