Skip to content

Commit

Permalink
right-click tap handler for replies
Browse files Browse the repository at this point in the history
  • Loading branch information
resolritter committed Aug 31, 2021
1 parent 8e5060b commit d6fc751
Showing 1 changed file with 47 additions and 5 deletions.
52 changes: 47 additions & 5 deletions resources/qml/delegates/Reply.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -36,9 +37,38 @@ Item {
width: parent.width
height: replyContainer.height

TapHandler {
onSingleTapped: chat.model.showEvent(eventId)
gesturePolicy: TapHandler.ReleaseWithinBounds
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)
}
}

CursorShape {
Expand All @@ -62,6 +92,19 @@ Item {
anchors.leftMargin: 4
width: parent.width - 8

TapHandler {
acceptedButtons: Qt.LeftButton
onSingleTapped: chat.model.showEvent(eventId)
gesturePolicy: TapHandler.ReleaseWithinBounds
}

TapHandler {
acceptedButtons: Qt.RightButton
onLongPressed: replyContextMenu.show(reply.child.copyText)
onSingleTapped: replyContextMenu.show(reply.child.copyText, reply.child.hoveredLink)
gesturePolicy: TapHandler.ReleaseWithinBounds
}

Text {
id: userName_

Expand All @@ -73,7 +116,6 @@ Item {
onSingleTapped: chat.model.openUserProfile(userId)
gesturePolicy: TapHandler.ReleaseWithinBounds
}

}

MessageDelegate {
Expand All @@ -99,11 +141,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 {
Expand Down

0 comments on commit d6fc751

Please sign in to comment.