From 5551791077b807689a0d581cfcbf6fc7b6c623a1 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 1 Jun 2020 15:38:19 +0300 Subject: [PATCH] QmlDesigner: Fix hover hightlight of 3D edit icon gizmos MouseArea.containsMouse gets confused when the mouse input gets grabbed by an overlapping 3D mouse area. Change-Id: I6ee69f217d95c5e4f3f5361e14c932ce0a2feab0 Fixes: QDS-2187 Reviewed-by: Thomas Hartmann --- .../qml/qmlpuppet/mockfiles/IconGizmo.qml | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml index 6f7707ca895..10de1f224cd 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml @@ -42,11 +42,17 @@ Item { } return false; } + property bool hasMouse: false property alias iconSource: iconImage.source signal clicked(Node node, bool multi) + onSelectedChanged: { + if (selected) + hasMouse = false; + } + visible: activeScene === scene && (targetNode ? targetNode.visible : false) Overlay2D { @@ -57,14 +63,14 @@ Item { Rectangle { id: iconRect + width: iconImage.width height: iconImage.height x: -width / 2 y: -height / 2 color: "transparent" border.color: "#7777ff" - border.width: !iconGizmo.selected - && iconGizmo.highlightOnHover && iconMouseArea.containsMouse ? 2 : 0 + border.width: iconGizmo.highlightOnHover && iconGizmo.hasMouse ? 2 : 0 radius: 5 opacity: iconGizmo.selected ? 0.2 : 1 Image { @@ -86,6 +92,24 @@ Item { mouse.modifiers & Qt.ControlModifier) hoverEnabled: iconGizmo.highlightOnHover && !iconGizmo.selected acceptedButtons: Qt.LeftButton + + // onPositionChanged, onContainsMouseAreaChanged, and hasMouse are used instead + // of just using containsMouse directly, because containsMouse + // cannot be relied upon to update correctly in some situations. + // This is likely because the overlapping 3D mouse areas of the gizmos get + // the mouse events instead of this area, so mouse leaving the area + // doesn't always update containsMouse property. + onPositionChanged: { + if (!iconGizmo.selected) + iconGizmo.hasMouse = containsMouse; + } + + onContainsMouseChanged: { + if (!iconGizmo.selected) + iconGizmo.hasMouse = containsMouse; + else + iconGizmo.hasMouse = false; + } } } }