This commit is contained in:
Ly-sec
2025-11-07 14:49:17 +01:00
2 changed files with 17 additions and 8 deletions
+13 -4
View File
@@ -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
+4 -4
View File
@@ -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