diagrams: Meta+click-drag to pan fullscreen viewer
Left-click drag was unreliable for panning. Use Meta (Super/Win key) + left-click-drag instead. Flickable interactive mode disabled; panning is handled manually via MouseArea.
This commit is contained in:
parent
c76a144de2
commit
931cadb3ce
|
|
@ -1469,6 +1469,7 @@ Item {
|
||||||
contentWidth: diagramZoomImg.width
|
contentWidth: diagramZoomImg.width
|
||||||
contentHeight: diagramZoomImg.height
|
contentHeight: diagramZoomImg.height
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
interactive: false // disable default drag — we handle it via Meta+drag
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: diagramZoomImg
|
id: diagramZoomImg
|
||||||
|
|
@ -1485,6 +1486,31 @@ Item {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
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.MetaModifier)) {
|
||||||
|
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
|
||||||
|
}
|
||||||
onClicked: function(mouse) {
|
onClicked: function(mouse) {
|
||||||
if (mouse.button === Qt.RightButton)
|
if (mouse.button === Qt.RightButton)
|
||||||
diagramFullscreen.close()
|
diagramFullscreen.close()
|
||||||
|
|
|
||||||
|
|
@ -2279,6 +2279,7 @@ ApplicationWindow {
|
||||||
contentWidth: diagramZoomImg.width
|
contentWidth: diagramZoomImg.width
|
||||||
contentHeight: diagramZoomImg.height
|
contentHeight: diagramZoomImg.height
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
interactive: false // disable default drag — we handle it via Meta+drag
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: diagramZoomImg
|
id: diagramZoomImg
|
||||||
|
|
@ -2294,6 +2295,31 @@ ApplicationWindow {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
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.MetaModifier)) {
|
||||||
|
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
|
||||||
|
}
|
||||||
onClicked: function(mouse) {
|
onClicked: function(mouse) {
|
||||||
if (mouse.button === Qt.RightButton)
|
if (mouse.button === Qt.RightButton)
|
||||||
diagramFullscreen.close()
|
diagramFullscreen.close()
|
||||||
|
|
|
||||||
Reference in New Issue