dock: fix window title alignment on popup

This commit is contained in:
end-4
2026-04-13 18:40:30 +02:00
parent a9dcab5e41
commit 96bf8dcbf0
@@ -1,3 +1,4 @@
pragma ComponentBehavior: Bound
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
@@ -27,8 +28,8 @@ Item {
function popupCenterXForButton(button) { function popupCenterXForButton(button) {
if (!button || !root.QsWindow) if (!button || !root.QsWindow)
return 0 return 0;
return root.QsWindow.mapFromItem(button, button.width / 2, 0).x return root.QsWindow.mapFromItem(button, button.width / 2, 0).x;
} }
StyledListView { StyledListView {
@@ -63,10 +64,7 @@ Item {
id: previewPopup id: previewPopup
property var appTopLevel: root.lastHoveredButton?.appToplevel property var appTopLevel: root.lastHoveredButton?.appToplevel
property bool shouldShow: (popupMouseArea.containsMouse || root.buttonHovered) property bool shouldShow: (popupMouseArea.containsMouse || root.buttonHovered) && appTopLevel && appTopLevel.toplevels && appTopLevel.toplevels.length > 0
&& appTopLevel
&& appTopLevel.toplevels
&& appTopLevel.toplevels.length > 0
property bool show: false property bool show: false
property real cachedCenterX: 0 property real cachedCenterX: 0
@@ -75,24 +73,24 @@ Item {
target: root target: root
function onLastHoveredButtonChanged() { function onLastHoveredButtonChanged() {
if (root.lastHoveredButton && root.QsWindow) if (root.lastHoveredButton && root.QsWindow)
previewPopup.cachedCenterX = root.popupCenterXForButton(root.lastHoveredButton) previewPopup.cachedCenterX = root.popupCenterXForButton(root.lastHoveredButton);
} }
function onButtonHoveredChanged() { function onButtonHoveredChanged() {
if (root.buttonHovered && root.lastHoveredButton && root.QsWindow) if (root.buttonHovered && root.lastHoveredButton && root.QsWindow)
previewPopup.cachedCenterX = root.popupCenterXForButton(root.lastHoveredButton) previewPopup.cachedCenterX = root.popupCenterXForButton(root.lastHoveredButton);
updateTimer.restart() updateTimer.restart();
} }
} }
onShouldShowChanged: { onShouldShowChanged: {
updateTimer.restart() updateTimer.restart();
} }
Timer { Timer {
id: updateTimer id: updateTimer
interval: 100 interval: 100
onTriggered: { onTriggered: {
previewPopup.show = previewPopup.shouldShow previewPopup.show = previewPopup.shouldShow;
} }
} }
@@ -157,6 +155,7 @@ Item {
} }
RippleButton { RippleButton {
id: windowButton id: windowButton
Layout.fillHeight: true
required property var modelData required property var modelData
padding: 0 padding: 0
middleClickAction: () => { middleClickAction: () => {
@@ -182,8 +181,8 @@ Item {
GroupButton { GroupButton {
id: closeButton id: closeButton
colBackground: ColorUtils.transparentize(Appearance.colors.colSurfaceContainer) colBackground: ColorUtils.transparentize(Appearance.colors.colSurfaceContainer)
baseWidth: windowControlsHeight baseWidth: root.windowControlsHeight
baseHeight: windowControlsHeight baseHeight: root.windowControlsHeight
buttonRadius: Appearance.rounding.full buttonRadius: Appearance.rounding.full
contentItem: MaterialSymbol { contentItem: MaterialSymbol {
anchors.centerIn: parent anchors.centerIn: parent
@@ -197,18 +196,25 @@ Item {
} }
} }
} }
ScreencopyView { Item {
id: screencopyView Layout.fillWidth: true
captureSource: windowButton.modelData Layout.fillHeight: true
live: true implicitHeight: screencopyView.height
paintCursor: true implicitWidth: screencopyView.width
constraintSize: Qt.size(root.maxWindowPreviewWidth, root.maxWindowPreviewHeight) ScreencopyView {
layer.enabled: true id: screencopyView
layer.effect: OpacityMask { anchors.centerIn: parent
maskSource: Rectangle { captureSource: windowButton.modelData
width: screencopyView.width live: true
height: screencopyView.height paintCursor: true
radius: Appearance.rounding.small constraintSize: Qt.size(root.maxWindowPreviewWidth, root.maxWindowPreviewHeight)
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Rectangle {
width: screencopyView.width
height: screencopyView.height
radius: Appearance.rounding.small
}
} }
} }
} }