summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorresolritter <joao.paulo.silvasouza@hotmail.com>2021-08-25 11:10:55 -0300
committerresolritter <joao.paulo.silvasouza@hotmail.com>2021-08-31 16:45:44 -0300
commit3f8bb19ba1fed05d0a19ce16690f88c09f3aed79 (patch)
tree36f8275e82fc8963e9b796e80b6638f746a5703f /resources
parentTranslated using Weblate (German) (diff)
downloadnheko-3f8bb19ba1fed05d0a19ce16690f88c09f3aed79.tar.xz
right-click tap handler for replies
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/MessageView.qml34
-rw-r--r--resources/qml/delegates/Reply.qml28
-rw-r--r--resources/qml/delegates/TextMessage.qml7
3 files changed, 62 insertions, 7 deletions
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml

index e5c6b4ec..251e5ff1 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml
@@ -648,4 +648,38 @@ ScrollView { } + Platform.Menu { + id: replyContextMenu + + property string text + property string link + + function show(text_, link_) { + text = text_; + link = link_; + open(); + } + + Platform.MenuItem { + visible: replyContextMenu.text + enabled: visible + text: qsTr("&Copy") + onTriggered: Clipboard.text = replyContextMenu.text + } + + Platform.MenuItem { + visible: replyContextMenu.link + enabled: visible + text: qsTr("Copy &link location") + onTriggered: Clipboard.text = replyContextMenu.link + } + + Platform.MenuItem { + visible: true + enabled: visible + text: qsTr("&Go to reply") + onTriggered: chat.model.showEvent(eventId) + } + } + } diff --git a/resources/qml/delegates/Reply.qml b/resources/qml/delegates/Reply.qml
index 8bbce10e..6c0a6da4 100644 --- a/resources/qml/delegates/Reply.qml +++ b/resources/qml/delegates/Reply.qml
@@ -7,6 +7,7 @@ import QtQuick.Controls 2.3 import QtQuick.Layouts 1.2 import QtQuick.Window 2.13 import im.nheko 1.0 +import Qt.labs.platform 1.1 as Platform Item { id: r @@ -36,11 +37,6 @@ Item { width: parent.width height: replyContainer.height - TapHandler { - onSingleTapped: chat.model.showEvent(eventId) - gesturePolicy: TapHandler.ReleaseWithinBounds - } - CursorShape { anchors.fill: parent cursorShape: Qt.PointingHandCursor @@ -62,6 +58,25 @@ Item { anchors.leftMargin: 4 width: parent.width - 8 + TapHandler { + acceptedButtons: Qt.LeftButton + onSingleTapped: chat.model.showEvent(r.eventId) + gesturePolicy: TapHandler.ReleaseWithinBounds + } + + TapHandler { + acceptedButtons: Qt.RightButton + onLongPressed: replyContextMenu.show( + reply.child.copyText, + reply.child.linkAt(eventPoint.position.x, eventPoint.position.y - userName_.implicitHeight) + ) + onSingleTapped: replyContextMenu.show( + reply.child.copyText, + reply.child.linkAt(eventPoint.position.x, eventPoint.position.y - userName_.implicitHeight) + ) + gesturePolicy: TapHandler.ReleaseWithinBounds + } + Text { id: userName_ @@ -73,7 +88,6 @@ Item { onSingleTapped: chat.model.openUserProfile(userId) gesturePolicy: TapHandler.ReleaseWithinBounds } - } MessageDelegate { @@ -99,11 +113,11 @@ Item { callType: r.callType relatedEventCacheBuster: r.relatedEventCacheBuster encryptionError: r.encryptionError + // This is disabled so that left clicking the reply goes to its location enabled: false width: parent.width isReply: true } - } Rectangle { diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml
index 58aa99ca..0bc45a9c 100644 --- a/resources/qml/delegates/TextMessage.qml +++ b/resources/qml/delegates/TextMessage.qml
@@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later import ".." +import QtQuick.Controls 2.3 import im.nheko 1.0 MatrixText { @@ -35,4 +36,10 @@ MatrixText { clip: isReply selectByMouse: !Settings.mobileMode && !isReply font.pointSize: (Settings.enlargeEmojiOnlyMessages && isOnlyEmoji > 0 && isOnlyEmoji < 4) ? Settings.fontSize * 3 : Settings.fontSize + + CursorShape { + enabled: isReply + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + } }