From a32d999e46a9b1ca78cf7389cf35ba1961d34593 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Fri, 14 Nov 2025 09:26:17 -0500 Subject: [PATCH] SmartPaneWindow: unload when not in use --- Modules/MainScreen/SmartPanel.qml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Modules/MainScreen/SmartPanel.qml b/Modules/MainScreen/SmartPanel.qml index 7574beeb..fda4c738 100644 --- a/Modules/MainScreen/SmartPanel.qml +++ b/Modules/MainScreen/SmartPanel.qml @@ -43,8 +43,8 @@ Item { // Support close with escape property bool closeWithEscape: true - // Track if window has been created (for lazy loading) - property bool windowCreated: false + // Track if window should be active (for lazy loading and cleanup) + property bool windowActive: false // Expose panel state (from content window) readonly property bool isPanelOpen: windowLoader.item ? windowLoader.item.isPanelOpen : false @@ -77,8 +77,8 @@ Item { // Public control functions function toggle(buttonItem, buttonName) { // Ensure window is created before toggling - if (!windowCreated) { - windowCreated = true + if (!root.windowActive) { + root.windowActive = true Qt.callLater(function () { if (windowLoader.item) { windowLoader.item.toggle(buttonItem, buttonName) @@ -91,8 +91,8 @@ Item { function open(buttonItem, buttonName) { // Ensure window is created before opening - if (!windowCreated) { - windowCreated = true + if (!root.windowActive) { + root.windowActive = true Qt.callLater(function () { if (windowLoader.item) { windowLoader.item.open(buttonItem, buttonName) @@ -143,10 +143,10 @@ Item { parent: root.parent } - // Lazy-load the content window (only created on first open) + // Lazy-load the content window (only created when open, destroyed when closed) Loader { id: windowLoader - active: root.windowCreated + active: root.windowActive sourceComponent: SmartPanelWindow { placeholder: panelPlaceholder panelContent: root.panelContent @@ -156,7 +156,13 @@ Item { // Forward signals onPanelOpened: root.opened() - onPanelClosed: root.closed() + onPanelClosed: { + root.closed() + // Destroy the window after close animation completes + Qt.callLater(function () { + root.windowActive = false + }) + } } }