Make it so that the menus for individual thread messages can be accessed

This is mostly just for text type messages at the moment but give the framework so that when other message types can be sent in threads they can be added easily
This commit is contained in:
James Graham
2025-03-15 16:03:27 +00:00
parent 4a800f99e1
commit 24235174fd
11 changed files with 137 additions and 50 deletions

View File

@@ -15,6 +15,20 @@ import org.kde.neochat
TextEdit {
id: root
/**
* @brief The matrix ID of the message event.
*/
required property string eventId
/**
* @brief The message author.
*
* A Quotient::RoomMember object.
*
* @sa Quotient::RoomMember
*/
required property NeochatRoomMember author
/**
* @brief The display text of the message.
*/
@@ -35,11 +49,6 @@ TextEdit {
*/
property bool spoilerRevealed: !hasSpoiler.test(display)
/**
* @brief Request a context menu be show for the message.
*/
signal showMessageMenu
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumWidth: Message.maxContentWidth
@@ -119,7 +128,6 @@ a{
HoverHandler {
cursorShape: (root.hoveredLink || !spoilerRevealed) ? Qt.PointingHandCursor : Qt.IBeamCursor
}
TapHandler {
enabled: !root.hoveredLink && !spoilerRevealed
onTapped: spoilerRevealed = true
@@ -128,6 +136,12 @@ a{
enabled: !root.hoveredLink
acceptedButtons: Qt.LeftButton
acceptedDevices: PointerDevice.TouchScreen
onLongPressed: root.showMessageMenu()
onLongPressed: RoomManager.viewEventMenu(root.eventId, root.Message.room, root.author, root.Message.selectedText, root.Message.hoveredLink);
}
TapHandler {
acceptedButtons: Qt.RightButton
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | PointerDevice.Stylus
gesturePolicy: TapHandler.WithinBounds
onTapped: RoomManager.viewEventMenu(root.eventId, root.Message.room, root.author, root.Message.selectedText, root.Message.hoveredLink);
}
}