fix(@desktop/chat)!: adjust image context menu size and position

Fixes #6830

Requires https://github.com/status-im/StatusQ/pull/852

BREAKING CHANGE: StatusImageModal clicked signal contains MouseEvent now
This commit is contained in:
PavelS 2022-08-12 12:20:23 +03:00 committed by PavelS
parent fbc10e7665
commit 78969cb8e0
5 changed files with 20 additions and 10 deletions

@ -1 +1 @@
Subproject commit e1d8d934b327df616dfc0afe084f0902ebb8b300
Subproject commit 76cc5fda2254d9739da61df9bdb9ac5b23fa9513

View File

@ -140,12 +140,15 @@ Item {
StatusImageModal {
id: imagePopup
onClicked: {
if (button === Qt.LeftButton) {
if (mouse.button === Qt.LeftButton) {
imagePopup.close()
} else if(button === Qt.RightButton) {
} else if(mouse.button === Qt.RightButton) {
contextMenu.imageSource = imagePopup.imageSource
contextMenu.hideEmojiPicker = true
contextMenu.isRightClickOnImage = true;
contextMenu.isRightClickOnImage = true
contextMenu.parent = imagePopup.contentItem
contextMenu.setXPosition = function() { return mouse.x + Style.current.smallPadding }
contextMenu.setYPosition = function() { return mouse.y - Style.current.smallPadding }
contextMenu.show()
}
}

View File

@ -10,7 +10,7 @@ import shared 1.0
Popup {
id: root
signal clicked(var button)
signal clicked(var mouse)
property string imageSource: messageImage.source
property var contextMenu
@ -61,7 +61,7 @@ Popup {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
root.clicked(mouse.button)
root.clicked(mouse)
}
}
}

View File

@ -578,8 +578,14 @@ Item {
else if (mouse.button === Qt.RightButton) {
// Set parent, X & Y positions for the messageContextMenu
root.messageContextMenu.parent = root
root.messageContextMenu.setXPosition = function() { return (mouse.x)}
root.messageContextMenu.setYPosition = function() { return (mouse.y)}
const mappedPos = root.mapFromItem(
this,
mouse.x + Style.current.smallPadding,
mouse.y - Style.current.smallPadding)
root.messageContextMenu.setXPosition = function() { return mappedPos.x }
root.messageContextMenu.setYPosition = function() { return mappedPos.y }
root.clickMessage(false, false, true, image, false, true, false, true, imageSource)
}
}

View File

@ -150,7 +150,8 @@ StatusPopupMenu {
y = setYPosition()
}
width: Math.max(emojiContainer.visible ? emojiContainer.width : 0, 230)
width: Math.max(emojiContainer.visible ? emojiContainer.width : 0,
(root.isRightClickOnImage && !root.pinnedPopup) ? 176 : 230)
onAboutToShow: {
if (root.isProfile && root.selectedUserPublicKey !== "") {
@ -208,7 +209,7 @@ StatusPopupMenu {
Item {
visible: root.isProfile
height: root.topPadding
height: visible ? root.topPadding : 0
}
Separator {