fix(UserImage): fix context menu placement

previously, the context menu would be randomly placed; now the image gets
access to its context menu and allows for placing it precisely, just like
it's done in UsernameLabel
This commit is contained in:
Lukáš Tinkl 2022-07-21 12:57:41 +02:00 committed by Iuri Matias
parent 9ad23c24d7
commit 9ddd75c8f5
2 changed files with 11 additions and 1 deletions

View File

@ -18,6 +18,7 @@ Loader {
property string image
property bool showRing: true
property bool interactive: true
property var messageContextMenu
property int colorId: Utils.colorIdForPubkey(pubkey)
property var colorHash: Utils.getColorHashAsJson(pubkey)
@ -49,7 +50,15 @@ Loader {
sourceComponent: MouseArea {
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: root.clicked()
onClicked: {
if (!!root.messageContextMenu) {
// Set parent, X & Y positions for the messageContextMenu
root.messageContextMenu.parent = root
root.messageContextMenu.setXPosition = function() { return root.width + 4 }
root.messageContextMenu.setYPosition = function() { return 0 }
}
root.clicked()
}
}
}
}

View File

@ -365,6 +365,7 @@ Item {
image: root.senderIcon
pubkey: senderId
name: senderDisplayName
messageContextMenu: root.messageContextMenu
onClicked: root.clickMessage(true, false, false, null, false, false, false, false, "")
}