Merge pull request #696 from resolritter/reply

Right-click tap handler for replies
This commit is contained in:
DeepBlueV7.X 2021-09-03 09:43:13 +00:00 committed by GitHub
commit 5d6c26c8c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 7 deletions

View file

@ -650,4 +650,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)
}
}
} }

View file

@ -7,6 +7,7 @@ import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import QtQuick.Window 2.13 import QtQuick.Window 2.13
import im.nheko 1.0 import im.nheko 1.0
import Qt.labs.platform 1.1 as Platform
Item { Item {
id: r id: r
@ -36,11 +37,6 @@ Item {
width: parent.width width: parent.width
height: replyContainer.height height: replyContainer.height
TapHandler {
onSingleTapped: chat.model.showEvent(eventId)
gesturePolicy: TapHandler.ReleaseWithinBounds
}
CursorShape { CursorShape {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
@ -62,6 +58,25 @@ Item {
anchors.leftMargin: 4 anchors.leftMargin: 4
width: parent.width - 8 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 { Text {
id: userName_ id: userName_
@ -73,7 +88,6 @@ Item {
onSingleTapped: chat.model.openUserProfile(userId) onSingleTapped: chat.model.openUserProfile(userId)
gesturePolicy: TapHandler.ReleaseWithinBounds gesturePolicy: TapHandler.ReleaseWithinBounds
} }
} }
MessageDelegate { MessageDelegate {
@ -99,11 +113,11 @@ Item {
callType: r.callType callType: r.callType
relatedEventCacheBuster: r.relatedEventCacheBuster relatedEventCacheBuster: r.relatedEventCacheBuster
encryptionError: r.encryptionError encryptionError: r.encryptionError
// This is disabled so that left clicking the reply goes to its location
enabled: false enabled: false
width: parent.width width: parent.width
isReply: true isReply: true
} }
} }
Rectangle { Rectangle {

View file

@ -3,6 +3,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import ".." import ".."
import QtQuick.Controls 2.3
import im.nheko 1.0 import im.nheko 1.0
MatrixText { MatrixText {
@ -35,4 +36,10 @@ MatrixText {
clip: isReply clip: isReply
selectByMouse: !Settings.mobileMode && !isReply selectByMouse: !Settings.mobileMode && !isReply
font.pointSize: (Settings.enlargeEmojiOnlyMessages && isOnlyEmoji > 0 && isOnlyEmoji < 4) ? Settings.fontSize * 3 : Settings.fontSize font.pointSize: (Settings.enlargeEmojiOnlyMessages && isOnlyEmoji > 0 && isOnlyEmoji < 4) ? Settings.fontSize * 3 : Settings.fontSize
CursorShape {
enabled: isReply
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
}
} }