Merge branch 'main' into hefty-hype

This commit is contained in:
end-4
2026-04-16 22:33:02 +02:00
@@ -1,3 +1,4 @@
pragma ComponentBehavior: Bound
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
@@ -17,14 +18,20 @@ Item {
property real windowControlsHeight: 30 property real windowControlsHeight: 30
property real buttonPadding: 5 property real buttonPadding: 5
property Item lastHoveredButton property Item lastHoveredButton: null
property bool buttonHovered: false property bool buttonHovered: false
property bool requestDockShow: previewPopup.show property bool requestDockShow: previewPopup.show
Layout.fillHeight: true Layout.fillHeight: true
Layout.topMargin: Appearance.sizes.hyprlandGapsOut // why does this work Layout.topMargin: Appearance.sizes.hyprlandGapsOut
implicitWidth: listView.implicitWidth implicitWidth: listView.implicitWidth
function popupCenterXForButton(button) {
if (!button || !root.QsWindow)
return 0;
return root.QsWindow.mapFromItem(button, button.width / 2, 0).x;
}
StyledListView { StyledListView {
id: listView id: listView
spacing: 2 spacing: 2
@@ -56,52 +63,45 @@ Item {
PopupWindow { PopupWindow {
id: previewPopup id: previewPopup
property var appTopLevel: root.lastHoveredButton?.appToplevel property var appTopLevel: root.lastHoveredButton?.appToplevel
property bool allPreviewsReady: false
property bool shouldShow: (popupMouseArea.containsMouse || root.buttonHovered) && appTopLevel && appTopLevel.toplevels && appTopLevel.toplevels.length > 0
property bool show: false
property real cachedCenterX: 0
Connections { Connections {
target: root target: root
function onLastHoveredButtonChanged() { function onLastHoveredButtonChanged() {
previewPopup.allPreviewsReady = false; // Reset readiness when the hovered button changes if (root.lastHoveredButton && root.QsWindow)
} previewPopup.cachedCenterX = root.popupCenterXForButton(root.lastHoveredButton);
} }
function updatePreviewReadiness() { function onButtonHoveredChanged() {
for(var i = 0; i < previewRowLayout.children.length; i++) { if (root.buttonHovered && root.lastHoveredButton && root.QsWindow)
const view = previewRowLayout.children[i]; previewPopup.cachedCenterX = root.popupCenterXForButton(root.lastHoveredButton);
if (view.hasContent === false) { updateTimer.restart();
allPreviewsReady = false;
return;
}
} }
allPreviewsReady = true;
} }
property bool shouldShow: {
const hoverConditions = (popupMouseArea.containsMouse || root.buttonHovered)
return hoverConditions && allPreviewsReady;
}
property bool show: false
onShouldShowChanged: { onShouldShowChanged: {
if (shouldShow) { updateTimer.restart();
// show = true;
updateTimer.restart();
} else {
updateTimer.restart();
}
} }
Timer { Timer {
id: updateTimer id: updateTimer
interval: 100 interval: 100
onTriggered: { onTriggered: {
previewPopup.show = previewPopup.shouldShow previewPopup.show = previewPopup.shouldShow;
} }
} }
anchor { anchor {
window: root.QsWindow.window window: root.QsWindow.window
adjustment: PopupAdjustment.None adjustment: PopupAdjustment.None
gravity: Edges.Top | Edges.Right gravity: Edges.Top | Edges.Right
edges: Edges.Top | Edges.Left edges: Edges.Top | Edges.Left
} }
visible: popupBackground.visible
visible: popupBackground.opacity > 0
color: "transparent" color: "transparent"
implicitWidth: root.QsWindow.window?.width ?? 1 implicitWidth: root.QsWindow.window?.width ?? 1
implicitHeight: popupMouseArea.implicitHeight + root.windowControlsHeight + Appearance.sizes.elevationMargin * 2 implicitHeight: popupMouseArea.implicitHeight + root.windowControlsHeight + Appearance.sizes.elevationMargin * 2
@@ -112,10 +112,8 @@ Item {
implicitWidth: popupBackground.implicitWidth + Appearance.sizes.elevationMargin * 2 implicitWidth: popupBackground.implicitWidth + Appearance.sizes.elevationMargin * 2
implicitHeight: root.maxWindowPreviewHeight + root.windowControlsHeight + Appearance.sizes.elevationMargin * 2 implicitHeight: root.maxWindowPreviewHeight + root.windowControlsHeight + Appearance.sizes.elevationMargin * 2
hoverEnabled: true hoverEnabled: true
x: { x: previewPopup.cachedCenterX - width / 2
const itemCenter = root.QsWindow?.mapFromItem(root.lastHoveredButton, root.lastHoveredButton?.width / 2, 0);
return itemCenter.x - width / 2
}
StyledRectangularShadow { StyledRectangularShadow {
target: popupBackground target: popupBackground
opacity: previewPopup.show ? 1 : 0 opacity: previewPopup.show ? 1 : 0
@@ -124,6 +122,7 @@ Item {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
} }
Rectangle { Rectangle {
id: popupBackground id: popupBackground
property real padding: 5 property real padding: 5
@@ -156,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: () => {
@@ -181,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
@@ -196,21 +196,25 @@ Item {
} }
} }
} }
ScreencopyView { Item {
id: screencopyView Layout.fillWidth: true
captureSource: previewPopup ? windowButton.modelData : null Layout.fillHeight: true
live: true implicitHeight: screencopyView.height
paintCursor: true implicitWidth: screencopyView.width
constraintSize: Qt.size(root.maxWindowPreviewWidth, root.maxWindowPreviewHeight) ScreencopyView {
onHasContentChanged: { id: screencopyView
previewPopup.updatePreviewReadiness(); anchors.centerIn: parent
} captureSource: windowButton.modelData
layer.enabled: true live: true
layer.effect: OpacityMask { paintCursor: true
maskSource: Rectangle { constraintSize: Qt.size(root.maxWindowPreviewWidth, root.maxWindowPreviewHeight)
width: screencopyView.width layer.enabled: true
height: screencopyView.height layer.effect: OpacityMask {
radius: Appearance.rounding.small maskSource: Rectangle {
width: screencopyView.width
height: screencopyView.height
radius: Appearance.rounding.small
}
} }
} }
} }