From d92bbdb2bec93dcad0de7f30157f3584c677b665 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 24 Nov 2021 14:24:17 +0200 Subject: [PATCH] effects/overview: Load close button in WindowHeap on demand For many windows it will be invisible, so there's little point for creating it ahead of time. Another reason for loading the close button on demand is that Plasma components are typically heavy. --- src/effects/overview/qml/WindowHeap.qml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/effects/overview/qml/WindowHeap.qml b/src/effects/overview/qml/WindowHeap.qml index e6989ea6c4..8c7f9db462 100644 --- a/src/effects/overview/qml/WindowHeap.qml +++ b/src/effects/overview/qml/WindowHeap.qml @@ -229,17 +229,19 @@ FocusScope { } } - PC3.Button { + Loader { LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft - icon.name: "window-close" + active: (hoverHandler.hovered || Kirigami.Settings.tabletMode || Kirigami.Settings.hasTransientTouchInput) && thumb.client.closeable && !dragHandler.active anchors.right: thumbSource.right anchors.rightMargin: PlasmaCore.Units.largeSpacing anchors.top: thumbSource.top anchors.topMargin: PlasmaCore.Units.largeSpacing - implicitWidth: PlasmaCore.Units.iconSizes.medium - implicitHeight: implicitWidth - visible: (hovered || hoverHandler.hovered || Kirigami.Settings.tabletMode || Kirigami.Settings.hasTransientTouchInput) && thumb.client.closeable && !dragHandler.active - onClicked: thumb.client.closeWindow(); + sourceComponent: PC3.Button { + icon.name: "window-close" + implicitWidth: PlasmaCore.Units.iconSizes.medium + implicitHeight: implicitWidth + onClicked: thumb.client.closeWindow(); + } } Component.onDestruction: {