Restore reply context menu

delegate-rework
Nicolas Werner 1 year ago
parent 4d2a5d1e9b
commit a7af3bb96c
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 16
      resources/qml/MessageView.qml
  2. 19
      resources/qml/TimelineBubbleMessageStyle.qml
  3. 11
      resources/qml/TimelineDefaultMessageStyle.qml

@ -26,7 +26,7 @@ Item {
Connections { Connections {
function onHideMenu() { function onHideMenu() {
messageContextMenuC.close(); messageContextMenuC.close();
replyContextMenu.close(); replyContextMenuC.close();
} }
target: MainWindow target: MainWindow
@ -65,6 +65,7 @@ Item {
TimelineDefaultMessageStyle { TimelineDefaultMessageStyle {
messageActions: messageActionsC messageActions: messageActionsC
messageContextMenu: messageContextMenuC messageContextMenu: messageContextMenuC
replyContextMenu: replyContextMenuC
scrolledToThis: eventId === room.scrollTarget && (y + height > chat.y + chat.contentY && y < chat.y + chat.height + chat.contentY) scrolledToThis: eventId === room.scrollTarget && (y + height > chat.y + chat.contentY && y < chat.y + chat.height + chat.contentY)
} }
} }
@ -74,6 +75,7 @@ Item {
TimelineBubbleMessageStyle { TimelineBubbleMessageStyle {
messageActions: messageActionsC messageActions: messageActionsC
messageContextMenu: messageContextMenuC messageContextMenu: messageContextMenuC
replyContextMenu: replyContextMenuC
scrolledToThis: eventId === room.scrollTarget && (y + height > chat.y + chat.contentY && y < chat.y + chat.height + chat.contentY) scrolledToThis: eventId === room.scrollTarget && (y + height > chat.y + chat.contentY && y < chat.y + chat.height + chat.contentY)
} }
} }
@ -541,7 +543,7 @@ Item {
} }
} }
Platform.Menu { Platform.Menu {
id: replyContextMenu id: replyContextMenuC
property string eventId property string eventId
property string link property string link
@ -557,23 +559,23 @@ Item {
Platform.MenuItem { Platform.MenuItem {
enabled: visible enabled: visible
text: qsTr("&Copy") text: qsTr("&Copy")
visible: replyContextMenu.text visible: replyContextMenuC.text
onTriggered: Clipboard.text = replyContextMenu.text onTriggered: Clipboard.text = replyContextMenuC.text
} }
Platform.MenuItem { Platform.MenuItem {
enabled: visible enabled: visible
text: qsTr("Copy &link location") text: qsTr("Copy &link location")
visible: replyContextMenu.link visible: replyContextMenuC.link
onTriggered: Clipboard.text = replyContextMenu.link onTriggered: Clipboard.text = replyContextMenuC.link
} }
Platform.MenuItem { Platform.MenuItem {
enabled: visible enabled: visible
text: qsTr("&Go to quoted message") text: qsTr("&Go to quoted message")
visible: true visible: true
onTriggered: room.showEvent(replyContextMenu.eventId) onTriggered: room.showEvent(replyContextMenuC.eventId)
} }
} }
RoundButton { RoundButton {

@ -44,6 +44,7 @@ TimelineEvent {
required property bool isEditable required property bool isEditable
required property QtObject messageContextMenu required property QtObject messageContextMenu
required property QtObject replyContextMenu
required property Item messageActions required property Item messageActions
property int avatarMargin: (wrapper.isStateEvent || Settings.smallAvatars ? 0 : (Nheko.avatarSize + 8)) // align bubble with section header property int avatarMargin: (wrapper.isStateEvent || Settings.smallAvatars ? 0 : (Nheko.avatarSize + 8)) // align bubble with section header
@ -173,13 +174,14 @@ TimelineEvent {
contentItem: Item { contentItem: Item {
id: contentPlacementContainer id: contentPlacementContainer
property int metadataWidth: 100
property int metadataHeight: 20
property bool fitsMetadata: ((wrapper.main?.width ?? 0) + wrapper.mainInset + metadata.width) < wrapper.maxWidth 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)) // 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?
implicitHeight: contentColumn.implicitHeight + (fitsMetadata ? 0 : metadata.height) // 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 { TimelineMetadata {
id: metadata id: metadata
@ -275,6 +277,13 @@ TimelineEvent {
wrapper.room.showEvent(wrapper.replyTo) 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] data: [replyRow, wrapper.main]

@ -44,6 +44,7 @@ TimelineEvent {
required property bool isEditable required property bool isEditable
required property QtObject messageContextMenu required property QtObject messageContextMenu
required property QtObject replyContextMenu
required property Item messageActions required property Item messageActions
property int avatarMargin: (wrapper.isStateEvent || Settings.smallAvatars ? 0 : (Nheko.avatarSize + 8)) // align bubble with section header property int avatarMargin: (wrapper.isStateEvent || Settings.smallAvatars ? 0 : (Nheko.avatarSize + 8)) // align bubble with section header
@ -261,6 +262,13 @@ TimelineEvent {
wrapper.room.showEvent(wrapper.replyTo) 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: [ data: [
@ -292,14 +300,11 @@ TimelineEvent {
id: reactionRow id: reactionRow
eventId: wrapper.eventId eventId: wrapper.eventId
layoutDirection: row.bubbleOnRight ? Qt.RightToLeft : Qt.LeftToRight
reactions: wrapper.reactions reactions: wrapper.reactions
width: wrapper.width - wrapper.avatarMargin width: wrapper.width - wrapper.avatarMargin
x: wrapper.avatarMargin x: wrapper.avatarMargin
anchors { anchors {
//left: row.bubbleOnRight ? undefined : row.left
//right: row.bubbleOnRight ? row.right : undefined
top: gridContainer.bottom top: gridContainer.bottom
topMargin: -4 topMargin: -4
} }

Loading…
Cancel
Save