From 8bf26917ad0f9f8d74128fbb8d9ad2c8fd495068 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 26 Jul 2020 02:06:38 +0200 Subject: [PATCH] Make long press menu actually work --- resources/qml/MatrixText.qml | 3 ++- resources/qml/TimelineRow.qml | 29 ++++++++++++++++------------- resources/qml/TimelineView.qml | 6 +++++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/resources/qml/MatrixText.qml b/resources/qml/MatrixText.qml index 9a4f734..cbb55be 100644 --- a/resources/qml/MatrixText.qml +++ b/resources/qml/MatrixText.qml @@ -5,7 +5,7 @@ TextEdit { textFormat: TextEdit.RichText readOnly: true wrapMode: Text.Wrap - selectByMouse: true + selectByMouse: ma.containsMouse // try to make scrollable by finger but selectable by mouse color: colors.text onLinkActivated: { @@ -23,6 +23,7 @@ TextEdit { id: ma anchors.fill: parent propagateComposedEvents: true + hoverEnabled: true acceptedButtons: Qt.NoButton cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor } diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml index 8186db8..d1c2027 100644 --- a/resources/qml/TimelineRow.qml +++ b/resources/qml/TimelineRow.qml @@ -8,22 +8,25 @@ import im.nheko 1.0 import "./delegates" import "./emoji" -MouseArea { +Item { anchors.left: parent.left anchors.right: parent.right height: row.height - propagateComposedEvents: true - preventStealing: true - hoverEnabled: true - - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button === Qt.RightButton) - messageContextMenu.show(model.id, model.type, model.isEncrypted, row) - } - onPressAndHold: { - if (mouse.source === Qt.MouseEventNotSynthesized) - messageContextMenu.show(model.id, model.type, model.isEncrypted, row) + + MouseArea { + anchors.fill: parent + propagateComposedEvents: true + preventStealing: true + hoverEnabled: true + + acceptedButtons: Qt.AllButtons + onClicked: { + if (mouse.button === Qt.RightButton) + messageContextMenu.show(model.id, model.type, model.isEncrypted, row) + } + onPressAndHold: { + messageContextMenu.show(model.id, model.type, model.isEncrypted, row, mapToItem(timelineRoot, mouse.x, mouse.y)) + } } Rectangle { color: (settings.messageHoverHighlight && parent.containsMouse) ? colors.base : "transparent" diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 7bdeb01..8a5612d 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -42,10 +42,14 @@ Page { id: messageContextMenu modal: true - function show(eventId_, eventType_, isEncrypted_, showAt_) { + function show(eventId_, eventType_, isEncrypted_, showAt_, position) { eventId = eventId_ eventType = eventType_ isEncrypted = isEncrypted_ + + if (position) + popup(position, showAt_) + else popup(showAt_) }