From 78969cb8e003e4f5227a48ee8cf9b07c9e42d4f1 Mon Sep 17 00:00:00 2001 From: PavelS Date: Fri, 12 Aug 2022 12:20:23 +0300 Subject: [PATCH] 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 --- ui/StatusQ | 2 +- ui/app/mainui/AppMain.qml | 9 ++++++--- ui/imports/shared/status/StatusImageModal.qml | 4 ++-- ui/imports/shared/views/chat/CompactMessageView.qml | 10 ++++++++-- .../shared/views/chat/MessageContextMenuView.qml | 5 +++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ui/StatusQ b/ui/StatusQ index e1d8d934b3..76cc5fda22 160000 --- a/ui/StatusQ +++ b/ui/StatusQ @@ -1 +1 @@ -Subproject commit e1d8d934b327df616dfc0afe084f0902ebb8b300 +Subproject commit 76cc5fda2254d9739da61df9bdb9ac5b23fa9513 diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 0b88b12c31..02e1a53285 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -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() } } diff --git a/ui/imports/shared/status/StatusImageModal.qml b/ui/imports/shared/status/StatusImageModal.qml index 43844b9abd..7bd4cace9c 100644 --- a/ui/imports/shared/status/StatusImageModal.qml +++ b/ui/imports/shared/status/StatusImageModal.qml @@ -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) } } } diff --git a/ui/imports/shared/views/chat/CompactMessageView.qml b/ui/imports/shared/views/chat/CompactMessageView.qml index 22705e297c..fffd80a458 100644 --- a/ui/imports/shared/views/chat/CompactMessageView.qml +++ b/ui/imports/shared/views/chat/CompactMessageView.qml @@ -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) } } diff --git a/ui/imports/shared/views/chat/MessageContextMenuView.qml b/ui/imports/shared/views/chat/MessageContextMenuView.qml index b61e38858d..d8a327f46c 100644 --- a/ui/imports/shared/views/chat/MessageContextMenuView.qml +++ b/ui/imports/shared/views/chat/MessageContextMenuView.qml @@ -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 {