diff --git a/gui/ChatPane.qml b/gui/ChatPane.qml index de6ed94..d67f50a 100644 --- a/gui/ChatPane.qml +++ b/gui/ChatPane.qml @@ -1469,6 +1469,7 @@ Item { contentWidth: diagramZoomImg.width contentHeight: diagramZoomImg.height boundsBehavior: Flickable.StopAtBounds + interactive: false // disable default drag — we handle it via Meta+drag Image { id: diagramZoomImg @@ -1485,6 +1486,31 @@ 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.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) { if (mouse.button === Qt.RightButton) diagramFullscreen.close() diff --git a/gui/main-kf5.qml b/gui/main-kf5.qml index 27293df..5bdd3a6 100644 --- a/gui/main-kf5.qml +++ b/gui/main-kf5.qml @@ -2279,6 +2279,7 @@ ApplicationWindow { contentWidth: diagramZoomImg.width contentHeight: diagramZoomImg.height boundsBehavior: Flickable.StopAtBounds + interactive: false // disable default drag — we handle it via Meta+drag Image { id: diagramZoomImg @@ -2294,6 +2295,31 @@ 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.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) { if (mouse.button === Qt.RightButton) diagramFullscreen.close()