diff --git a/src/core/qml/DockPreview.qml b/src/core/qml/DockPreview.qml index a787fffafc..629278174a 100644 --- a/src/core/qml/DockPreview.qml +++ b/src/core/qml/DockPreview.qml @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd. // SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only import QtQuick @@ -76,6 +76,18 @@ Item { } } + function removeSurface(surfaceWrapper) { + if (!surfaceWrapper) + return; + + var index = desiredSurfaces.indexOf(surfaceWrapper); + if (index < 0) + return; + + desiredSurfaces.splice(index, 1); + updateModel(); + } + function activateWindow(surfaceWrapper) { console.debug(qLcDockPreview, "activate preview window: ", surfaceWrapper) Helper.forceActivateSurface(surfaceWrapper) @@ -471,6 +483,13 @@ Item { implicitHeight: root.isHorizontal ? 120 : Math.max(80, Math.min(120, 240 * wrapper.height / wrapper.width)) implicitWidth: root.isHorizontal ? Math.max(80, Math.min(240, 120 * wrapper.width / wrapper.height)) : 240 + Connections { + target: wrapper + function onAboutToBeInvalidated() { + listview.model.removeSurface(wrapper) + } + } + ListView.onRemove: { if (filterSurfaceModel.count) { isRemoving = true