[ui] Viewer Fisheye Circle: disable MouseArea when unused

As the events cannot be propagated all the time as needed, at least unload the MouseArea when unused so the events are propagated.
This commit is contained in:
Fabien Castan 2020-03-24 21:12:37 +01:00
parent f19797c58f
commit 9ef6eb48fc

View file

@ -59,37 +59,41 @@ Rectangle {
} }
} }
MouseArea { Loader {
id: mArea
enabled: !root.readOnly
anchors.fill: parent anchors.fill: parent
cursorShape: root.readOnly ? Qt.ArrowCursor : (controlModifierEnabled ? Qt.SizeBDiagCursor : (pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor)) active: !root.readOnly
propagateComposedEvents: true
property bool controlModifierEnabled: false sourceComponent: MouseArea {
onPositionChanged: { id: mArea
mArea.controlModifierEnabled = (mouse.modifiers & Qt.ControlModifier) anchors.fill: parent
mouse.accepted = false; cursorShape: root.readOnly ? Qt.ArrowCursor : (controlModifierEnabled ? Qt.SizeBDiagCursor : (pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor))
} propagateComposedEvents: true
acceptedButtons: Qt.LeftButton
hoverEnabled: true
drag.target: parent
drag.onActiveChanged: { property bool controlModifierEnabled: false
if(!drag.active) { onPositionChanged: {
moved(); mArea.controlModifierEnabled = (mouse.modifiers & Qt.ControlModifier)
mouse.accepted = false;
} }
} acceptedButtons: Qt.LeftButton
onPressed: { hoverEnabled: true
forceActiveFocus(); drag.target: root
}
onWheel: { drag.onActiveChanged: {
mArea.controlModifierEnabled = (wheel.modifiers & Qt.ControlModifier) if(!drag.active) {
if (wheel.modifiers & Qt.ControlModifier) { moved();
incrementRadius(wheel.angleDelta.y / 120.0); }
wheel.accepted = true; }
} else { onPressed: {
wheel.accepted = false; forceActiveFocus();
}
onWheel: {
mArea.controlModifierEnabled = (wheel.modifiers & Qt.ControlModifier)
if (wheel.modifiers & Qt.ControlModifier) {
incrementRadius(wheel.angleDelta.y / 120.0);
wheel.accepted = true;
} else {
wheel.accepted = false;
}
} }
} }
} }