summary refs log tree commit diff
path: root/resources/qml/TimelineBubbleMessageStyle.qml
diff options
context:
space:
mode:
Diffstat (limited to 'resources/qml/TimelineBubbleMessageStyle.qml')
-rw-r--r--resources/qml/TimelineBubbleMessageStyle.qml19
1 files changed, 14 insertions, 5 deletions
diff --git a/resources/qml/TimelineBubbleMessageStyle.qml b/resources/qml/TimelineBubbleMessageStyle.qml
index ef6aba6e..2df3d917 100644
--- a/resources/qml/TimelineBubbleMessageStyle.qml
+++ b/resources/qml/TimelineBubbleMessageStyle.qml
@@ -44,6 +44,7 @@ TimelineEvent {
     required property bool isEditable
 
     required property QtObject messageContextMenu
+    required property QtObject replyContextMenu
     required property Item messageActions
 
     property int avatarMargin: (wrapper.isStateEvent || Settings.smallAvatars ? 0 : (Nheko.avatarSize + 8)) // align bubble with section header
@@ -173,13 +174,14 @@ TimelineEvent {
                 contentItem: Item {
                     id: contentPlacementContainer
 
-                    property int metadataWidth: 100
-                    property int metadataHeight: 20
-
                     property bool fitsMetadata: ((wrapper.main?.width ?? 0) + wrapper.mainInset + metadata.width) < wrapper.maxWidth
 
-                    implicitWidth: Math.max((wrapper.reply?.width ?? 0) + wrapper.replyInset, (wrapper.main?.width ?? 0) + wrapper.mainInset + (fitsMetadata ? metadata.width : 0))
-                    implicitHeight: contentColumn.implicitHeight + (fitsMetadata ? 0 : metadata.height)
+                    // This doesnt work because of tables. They might have content in the top of the cell, while the background reaches to the bottom. Maybe using the textDocument we could do more?
+                    // property bool fitsMetadataInside: wrapper.main?.positionAt ? (wrapper.main.positionAt(wrapper.main.width, wrapper.main.height - 4) == wrapper.main.positionAt(wrapper.main.width - metadata.width, wrapper.main.height - 4)) : false
+                    property bool fitsMetadataInside: false
+
+                    implicitWidth: Math.max((wrapper.reply?.width ?? 0) + wrapper.replyInset, (wrapper.main?.width ?? 0) + wrapper.mainInset + ((fitsMetadata && !fitsMetadataInside) ? metadata.width : 0))
+                    implicitHeight: contentColumn.implicitHeight + ((fitsMetadata || fitsMetadataInside) ? 0 : metadata.height)
 
                     TimelineMetadata {
                         id: metadata
@@ -275,6 +277,13 @@ TimelineEvent {
                                     wrapper.room.showEvent(wrapper.replyTo)
                                 }
                             }
+                            onPressAndHold: wrapper.replyContextMenu.show(wrapper.reply.copyText ?? "", wrapper.reply.linkAt ? wrapper.reply.linkAt(pressX-replyLine.width - Nheko.paddingSmall, pressY - replyUserButton.implicitHeight) : "", wrapper.replyTo)
+                            TapHandler {
+                                acceptedButtons: Qt.RightButton
+                                onSingleTapped: (eventPoint) => wrapper.replyContextMenu.show(wrapper.reply.copyText ?? "", wrapper.reply.linkAt ? wrapper.reply.linkAt(eventPoint.position.x-replyLine.width - Nheko.paddingSmall, eventPoint.position.y - replyUserButton.implicitHeight) : "", wrapper.replyTo)
+                                gesturePolicy: TapHandler.ReleaseWithinBounds
+                                acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus | PointerDevice.TouchPad
+                            }
                         }
 
                         data: [replyRow, wrapper.main]