mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-28 14:05:21 -04:00
feat(popouts): enhance hover functionality and introduce hover dismiss features
This commit is contained in:
@@ -2,34 +2,27 @@ pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
|
||||
Item {
|
||||
HoverHandler {
|
||||
id: root
|
||||
|
||||
property bool enabled: false
|
||||
property var shouldDismiss: null
|
||||
|
||||
signal dismissRequested
|
||||
// Emitted on every hover move; passive to avoid blocking overlapping MouseAreas
|
||||
signal hoverMoved(real gx, real gy)
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
HoverHandler {
|
||||
id: hoverHandler
|
||||
enabled: root.enabled
|
||||
onPointChanged: {
|
||||
if (!root.enabled || !hoverHandler.hovered)
|
||||
return;
|
||||
const gp = root.mapToItem(null, hoverHandler.point.position.x, hoverHandler.point.position.y);
|
||||
root.hoverMoved(gp.x, gp.y);
|
||||
}
|
||||
onHoveredChanged: {
|
||||
if (hoverHandler.hovered || !root.enabled)
|
||||
return;
|
||||
if (typeof root.shouldDismiss === "function" && !root.shouldDismiss())
|
||||
return;
|
||||
root.dismissRequested();
|
||||
}
|
||||
onPointChanged: {
|
||||
if (!enabled || !hovered)
|
||||
return;
|
||||
const gp = parent.mapToItem(null, point.position.x, point.position.y);
|
||||
hoverMoved(gp.x, gp.y);
|
||||
}
|
||||
onHoveredChanged: {
|
||||
if (hovered || !enabled)
|
||||
return;
|
||||
if (typeof shouldDismiss === "function" && !shouldDismiss())
|
||||
return;
|
||||
dismissRequested();
|
||||
}
|
||||
|
||||
function cancelPending() {
|
||||
|
||||
Reference in New Issue
Block a user