diagrams: simplify pan — native Flickable drag, MouseArea only for wheel+right-click

Remove manual pan logic. Let Flickable handle drag-to-pan natively.
MouseArea only accepts RightButton (close) and wheel (zoom), so it
no longer steals left-click events from the Flickable.
This commit is contained in:
Levi Neely 2026-07-29 16:47:29 +02:00
parent 395f2890ae
commit 32c501a2c7
2 changed files with 2 additions and 56 deletions

View File

@ -1469,7 +1469,6 @@ Item {
contentWidth: diagramZoomImg.width
contentHeight: diagramZoomImg.height
boundsBehavior: Flickable.StopAtBounds
interactive: false // disable default drag — we handle it via Ctrl+drag
Image {
id: diagramZoomImg
@ -1485,37 +1484,11 @@ Item {
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
property real startX: 0
property real startY: 0
property real startContentX: 0
property real startContentY: 0
property bool panning: false
onPressed: function(mouse) {
if (mouse.button === Qt.LeftButton && (mouse.modifiers & Qt.ControlModifier)) {
panning = true
startX = mouse.x
startY = mouse.y
startContentX = diagramFlick.contentX
startContentY = diagramFlick.contentY
mouse.accepted = true
}
}
onPositionChanged: function(mouse) {
if (panning) {
diagramFlick.contentX = Math.max(0, Math.min(diagramFlick.contentWidth - diagramFlick.width, startContentX - (mouse.x - startX)))
diagramFlick.contentY = Math.max(0, Math.min(diagramFlick.contentHeight - diagramFlick.height, startContentY - (mouse.y - startY)))
}
}
onReleased: function(mouse) {
panning = false
}
acceptedButtons: Qt.RightButton
onClicked: function(mouse) {
if (mouse.button === Qt.RightButton)
diagramFullscreen.close()
}
onDoubleClicked: diagramFullscreen.close()
onWheel: function(wheel) {
let factor = wheel.angleDelta.y > 0 ? 1.15 : 0.87
let newZoom = Math.max(0.25, Math.min(10.0, diagramZoomImg.zoomFactor * factor))

View File

@ -2279,7 +2279,6 @@ ApplicationWindow {
contentWidth: diagramZoomImg.width
contentHeight: diagramZoomImg.height
boundsBehavior: Flickable.StopAtBounds
interactive: false // disable default drag — we handle it via Ctrl+drag
Image {
id: diagramZoomImg
@ -2294,37 +2293,11 @@ ApplicationWindow {
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
property real startX: 0
property real startY: 0
property real startContentX: 0
property real startContentY: 0
property bool panning: false
onPressed: function(mouse) {
if (mouse.button === Qt.LeftButton && (mouse.modifiers & Qt.ControlModifier)) {
panning = true
startX = mouse.x
startY = mouse.y
startContentX = diagramFlick.contentX
startContentY = diagramFlick.contentY
mouse.accepted = true
}
}
onPositionChanged: function(mouse) {
if (panning) {
diagramFlick.contentX = Math.max(0, Math.min(diagramFlick.contentWidth - diagramFlick.width, startContentX - (mouse.x - startX)))
diagramFlick.contentY = Math.max(0, Math.min(diagramFlick.contentHeight - diagramFlick.height, startContentY - (mouse.y - startY)))
}
}
onReleased: function(mouse) {
panning = false
}
acceptedButtons: Qt.RightButton
onClicked: function(mouse) {
if (mouse.button === Qt.RightButton)
diagramFullscreen.close()
}
onDoubleClicked: diagramFullscreen.close()
onWheel: function(wheel) {
var factor = wheel.angleDelta.y > 0 ? 1.15 : 0.87
var newZoom = Math.max(0.25, Math.min(10.0, diagramZoomImg.zoomFactor * factor))