Load close button in WindowHeapDelegate on demand

Most windows are typically not hovered, so we don't need to create
a Button for every one of them.
This commit is contained in:
Vlad Zahorodnii 2023-12-07 09:37:37 +02:00
parent 71dd6bac78
commit 8e2d0a3d7e

View file

@ -431,28 +431,29 @@ Item {
}
}
PC3.Button {
Loader {
id: closeButton
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
anchors {
right: thumbSource.right
top: thumbSource.top
margins: Kirigami.Units.smallSpacing
}
active: thumb.closeButtonVisible && (hoverHandler.hovered || Kirigami.Settings.tabletMode || Kirigami.Settings.hasTransientTouchInput) && thumb.window.closeable && !thumb.activeDragHandler.active
visible: thumb.closeButtonVisible && (hoverHandler.hovered || Kirigami.Settings.tabletMode || Kirigami.Settings.hasTransientTouchInput) && thumb.window.closeable && !thumb.activeDragHandler.active
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
sourceComponent: PC3.Button {
text: i18ndc("kwin", "@info:tooltip as in: 'close this window'", "Close window")
icon.name: "window-close"
display: PC3.AbstractButton.IconOnly
text: i18ndc("kwin", "@info:tooltip as in: 'close this window'", "Close window")
icon.name: "window-close"
display: PC3.AbstractButton.IconOnly
PC3.ToolTip.text: text
PC3.ToolTip.visible: hovered && display === PC3.AbstractButton.IconOnly
PC3.ToolTip.delay: Kirigami.Units.toolTipDelay
Accessible.name: text
PC3.ToolTip.text: text
PC3.ToolTip.visible: hovered && display === PC3.AbstractButton.IconOnly
PC3.ToolTip.delay: Kirigami.Units.toolTipDelay
Accessible.name: text
onClicked: thumb.window.closeWindow();
onClicked: thumb.window.closeWindow();
}
}
Component.onDestruction: {