fix(@desktop/chat): Emoji reaction Menu is incorrect
Added logic to set parent ,x and y positions from the place where the menu is opened fixes #2385
This commit is contained in:
parent
8f1ffd96a1
commit
f4baf7c738
|
@ -120,6 +120,11 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageContextMenu {
|
||||||
|
id: contextmenu
|
||||||
|
reactionModel: EmojiReactions { }
|
||||||
|
}
|
||||||
|
|
||||||
StackLayout {
|
StackLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
currentIndex: chatsModel.channelView.activeChannelIndex > -1 && chatGroupsListViewCount > 0 ? 0 : 1
|
currentIndex: chatsModel.channelView.activeChannelIndex > -1 && chatGroupsListViewCount > 0 ? 0 : 1
|
||||||
|
@ -131,10 +136,10 @@ Item {
|
||||||
imagePopup.close()
|
imagePopup.close()
|
||||||
}
|
}
|
||||||
else if(button === Qt.RightButton) {
|
else if(button === Qt.RightButton) {
|
||||||
messageContextMenu.imageSource = imagePopup.imageSource
|
contextmenu.imageSource = imagePopup.imageSource
|
||||||
messageContextMenu.hideEmojiPicker = true
|
contextmenu.hideEmojiPicker = true
|
||||||
messageContextMenu.isRightClickOnImage = true;
|
contextmenu.isRightClickOnImage = true;
|
||||||
messageContextMenu.show()
|
contextmenu.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,9 +300,7 @@ Item {
|
||||||
sourceComponent: ChatMessages {
|
sourceComponent: ChatMessages {
|
||||||
id: chatMessages
|
id: chatMessages
|
||||||
messageList: messages
|
messageList: messages
|
||||||
messageContextMenuInst: MessageContextMenu {
|
messageContextMenuInst: contextmenu
|
||||||
reactionModel: EmojiReactions { }
|
|
||||||
}
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
chatColumnLayout.userList = chatMessages.messageList.userList;
|
chatColumnLayout.userList = chatMessages.messageList.userList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,16 +191,10 @@ Item {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isImage && !isRightClickOnImage) {
|
|
||||||
imageClick(image);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isProfileClick) {
|
if (!isProfileClick) {
|
||||||
SelectedMessage.set(messageId, fromAuthor);
|
SelectedMessage.set(messageId, fromAuthor);
|
||||||
}
|
}
|
||||||
|
|
||||||
messageContextMenu.parent = root
|
|
||||||
messageContextMenu.messageId = root.messageId
|
messageContextMenu.messageId = root.messageId
|
||||||
messageContextMenu.contentType = root.contentType
|
messageContextMenu.contentType = root.contentType
|
||||||
messageContextMenu.linkUrls = root.linkUrls;
|
messageContextMenu.linkUrls = root.linkUrls;
|
||||||
|
@ -224,10 +218,8 @@ Item {
|
||||||
messageContextMenu.show(userName, fromAuthor, root.profileImageSource || identicon, plainText, nickname, emojiReactionsModel);
|
messageContextMenu.show(userName, fromAuthor, root.profileImageSource || identicon, plainText, nickname, emojiReactionsModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position the center of the menu where the mouse is
|
messageContextMenu.x = messageContextMenu.setXPosition()
|
||||||
if (messageContextMenu.x + messageContextMenu.width + Style.current.padding < root.width) {
|
messageContextMenu.y = messageContextMenu.setYPosition()
|
||||||
messageContextMenu.x = messageContextMenu.x - messageContextMenu.width / 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
|
|
|
@ -65,13 +65,11 @@ Rectangle {
|
||||||
height: 32
|
height: 32
|
||||||
onClicked: {
|
onClicked: {
|
||||||
setMessageActive(messageId, true)
|
setMessageActive(messageId, true)
|
||||||
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
|
buttonsContainer.messageContextMenu.parent = buttonsContainer
|
||||||
|
buttonsContainer.messageContextMenu.setXPosition = function() { return (-Math.abs(buttonsContainer.width - buttonsContainer.messageContextMenu.emojiContainer.width))}
|
||||||
|
buttonsContainer.messageContextMenu.setYPosition = function() { return (-buttonsContainer.messageContextMenu.height - 4)}
|
||||||
clickMessage(false, false, false, null, true)
|
clickMessage(false, false, false, null, true)
|
||||||
if (!forceHoverHandler) {
|
|
||||||
buttonsContainer.messageContextMenu.x = buttonsContainer.x + buttonsContainer.width - buttonsContainer.messageContextMenu.width
|
|
||||||
|
|
||||||
// The Math.max is to make sure that the menu is rendered
|
|
||||||
buttonsContainer.messageContextMenu.y -= Math.max(buttonsContainer.messageContextMenu.emojiContainer.height, 56) + Style.current.padding
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onHoveredChanged: {
|
onHoveredChanged: {
|
||||||
buttonsContainer.hoverChanged(this.hovered)
|
buttonsContainer.hoverChanged(this.hovered)
|
||||||
|
@ -140,9 +138,11 @@ Rectangle {
|
||||||
if (typeof isMessageActive !== "undefined") {
|
if (typeof isMessageActive !== "undefined") {
|
||||||
setMessageActive(messageId, true)
|
setMessageActive(messageId, true)
|
||||||
}
|
}
|
||||||
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
|
buttonsContainer.messageContextMenu.parent = buttonsContainer
|
||||||
|
buttonsContainer.messageContextMenu.setXPosition = function() { return (-Math.abs(buttonsContainer.width - 176))}
|
||||||
|
buttonsContainer.messageContextMenu.setYPosition = function() { return (-buttonsContainer.messageContextMenu.height - 4)}
|
||||||
clickMessage(false, isSticker, false, null, false, true);
|
clickMessage(false, isSticker, false, null, false, true);
|
||||||
buttonsContainer.messageContextMenu.x = buttonsContainer.x + buttonsContainer.width - buttonsContainer.messageContextMenu.width
|
|
||||||
messageContextMenu.y = parent.height/2 + Style.current.smallPadding
|
|
||||||
}
|
}
|
||||||
onHoveredChanged: {
|
onHoveredChanged: {
|
||||||
buttonsContainer.hoverChanged(this.hovered)
|
buttonsContainer.hoverChanged(this.hovered)
|
||||||
|
|
|
@ -310,10 +310,14 @@ Item {
|
||||||
imageSource: image
|
imageSource: image
|
||||||
imageWidth: 200
|
imageWidth: 200
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
root.clickMessage(false, false, true, image)
|
imageClick(image)
|
||||||
}
|
}
|
||||||
else if (button === Qt.RightButton) {
|
else if (mouse.button === Qt.RightButton) {
|
||||||
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
|
messageContextMenu.parent = root
|
||||||
|
messageContextMenu.setXPosition = function() { return (mouse.x)}
|
||||||
|
messageContextMenu.setYPosition = function() { return (mouse.y)}
|
||||||
root.clickMessage(false, false, true, image, false, true, false, true, imageSource)
|
root.clickMessage(false, false, true, image, false, true, false, true, imageSource)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,11 +457,14 @@ Item {
|
||||||
|
|
||||||
sourceComponent: Component {
|
sourceComponent: Component {
|
||||||
EmojiReactions {
|
EmojiReactions {
|
||||||
|
id: emojiRect
|
||||||
onHoverChanged: setHovered(messageId, hovered)
|
onHoverChanged: setHovered(messageId, hovered)
|
||||||
onAddEmojiClicked: {
|
onAddEmojiClicked: {
|
||||||
root.addEmoji(false, false, false, null, true, false);
|
root.addEmoji(false, false, false, null, true, false);
|
||||||
messageContextMenu.x = (messageContainer.chatText.textField.leftPadding + 4);
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
messageContextMenu.y -= (56 + Style.current.padding);
|
messageContextMenu.parent = emojiReactionLoader
|
||||||
|
messageContextMenu.setXPosition = function() { return (messageContextMenu.parent.x + 4)}
|
||||||
|
messageContextMenu.setYPosition = function() { return (-messageContextMenu.height - 4)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ Column {
|
||||||
source: linkData.thumbnailUrl
|
source: linkData.thumbnailUrl
|
||||||
imageWidth: 300
|
imageWidth: 300
|
||||||
isCurrentUser: root.isCurrentUser
|
isCurrentUser: root.isCurrentUser
|
||||||
onClicked: clickMessage(false, false, true, linkImage.imageAlias)
|
onClicked: imageClick(linkImage.imageAlias)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,10 @@ MouseArea {
|
||||||
return clickMessage(false, isSticker, false)
|
return clickMessage(false, isSticker, false)
|
||||||
}
|
}
|
||||||
if(mouse.button === Qt.RightButton) {
|
if(mouse.button === Qt.RightButton) {
|
||||||
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
|
messageContextMenu.parent = root
|
||||||
|
messageContextMenu.setXPosition = function() { return (mouse.x)}
|
||||||
|
messageContextMenu.setYPosition = function() { return (mouse.y)}
|
||||||
clickMessage(false, isSticker, false)
|
clickMessage(false, isSticker, false)
|
||||||
if (typeof isMessageActive !== "undefined") {
|
if (typeof isMessageActive !== "undefined") {
|
||||||
setMessageActive(messageId, true)
|
setMessageActive(messageId, true)
|
||||||
|
|
|
@ -171,7 +171,7 @@ Item {
|
||||||
imageSource: image
|
imageSource: image
|
||||||
imageWidth: 250
|
imageWidth: 250
|
||||||
isCurrentUser: root.isCurrentUser
|
isCurrentUser: root.isCurrentUser
|
||||||
onClicked: root.clickMessage(false, false, true, image)
|
onClicked: imageClick(image)
|
||||||
container: root.container
|
container: root.container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ MouseArea {
|
||||||
StatusChatImage {
|
StatusChatImage {
|
||||||
imageSource: image
|
imageSource: image
|
||||||
imageWidth: 200
|
imageWidth: 200
|
||||||
onClicked: root.clickMessage(false, false, true, image)
|
onClicked: imageClick(image)
|
||||||
container: root.container
|
container: root.container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,10 @@ MouseArea {
|
||||||
icon.width: 20
|
icon.width: 20
|
||||||
icon.height: 20
|
icon.height: 20
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
|
messageContextMenu.parent = emojiBtn
|
||||||
|
messageContextMenu.setXPosition = function() { return -messageContextMenu.width + emojiBtn.width}
|
||||||
|
messageContextMenu.setYPosition = function() { return -messageContextMenu.height - 4}
|
||||||
root.clickMessage(false, false, false, null, true)
|
root.clickMessage(false, false, false, null, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,8 +138,10 @@ MouseArea {
|
||||||
EmojiReactions {
|
EmojiReactions {
|
||||||
onAddEmojiClicked: {
|
onAddEmojiClicked: {
|
||||||
root.addEmoji(false, false, false, null, true, false);
|
root.addEmoji(false, false, false, null, true, false);
|
||||||
messageContextMenu.x = (chatText.textField.leftPadding + 4);
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
messageContextMenu.y -= (56 + Style.current.padding);
|
messageContextMenu.parent = emojiReactionLoader
|
||||||
|
messageContextMenu.setXPosition = function() { return (messageContextMenu.parent.x + 4)}
|
||||||
|
messageContextMenu.setYPosition = function() { return (-messageContextMenu.height - 4)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ Loader {
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
|
messageContextMenu.parent = root
|
||||||
|
messageContextMenu.setXPosition = function() { return root.width + 4}
|
||||||
|
messageContextMenu.setYPosition = function() { return root.height/2 + 4}
|
||||||
clickMessage(true, false, false, null, false, false, isReplyImage)
|
clickMessage(true, false, false, null, false, false, isReplyImage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,10 @@ Item {
|
||||||
root.isHovered = false
|
root.isHovered = false
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
|
messageContextMenu.parent = root
|
||||||
|
messageContextMenu.setXPosition = function() { return 0}
|
||||||
|
messageContextMenu.setYPosition = function() { return root.height + 4}
|
||||||
clickMessage(true)
|
clickMessage(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,10 @@ Item {
|
||||||
openProfilePopup(wrapper.name, wrapper.publicKey, (wrapper.profileImage || wrapper.identicon), "", appMain.getUserNickname(wrapper.publicKey));
|
openProfilePopup(wrapper.name, wrapper.publicKey, (wrapper.profileImage || wrapper.identicon), "", appMain.getUserNickname(wrapper.publicKey));
|
||||||
}
|
}
|
||||||
else if (mouse.button === Qt.RightButton) {
|
else if (mouse.button === Qt.RightButton) {
|
||||||
|
// Set parent, X & Y positions for the messageContextMenu
|
||||||
|
messageContextMenu.parent = rectangle
|
||||||
|
messageContextMenu.setXPosition = function() { return 0}
|
||||||
|
messageContextMenu.setYPosition = function() { return rectangle.height}
|
||||||
messageContextMenu.isProfile = true;
|
messageContextMenu.isProfile = true;
|
||||||
messageContextMenu.show(wrapper.name, wrapper.publicKey, (wrapper.profileImage || wrapper.identicon), "", appMain.getUserNickname(wrapper.publicKey))
|
messageContextMenu.show(wrapper.name, wrapper.publicKey, (wrapper.profileImage || wrapper.identicon), "", appMain.getUserNickname(wrapper.publicKey))
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,21 @@ StatusPopupMenu {
|
||||||
property var onClickEdit: function(){}
|
property var onClickEdit: function(){}
|
||||||
property var reactionModel
|
property var reactionModel
|
||||||
property string imageSource: ""
|
property string imageSource: ""
|
||||||
|
property var setXPosition: function() {return 0}
|
||||||
|
property var setYPosition: function() {return 0}
|
||||||
property bool canPin: {
|
property bool canPin: {
|
||||||
const nbPinnedMessages = chatsModel.messageView.pinnedMessagesList.count
|
const nbPinnedMessages = chatsModel.messageView.pinnedMessagesList.count
|
||||||
return nbPinnedMessages < Constants.maxNumberOfPins
|
return nbPinnedMessages < Constants.maxNumberOfPins
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onHeightChanged: {
|
||||||
|
messageContextMenu.y = setYPosition()
|
||||||
|
}
|
||||||
|
|
||||||
|
onWidthChanged: {
|
||||||
|
messageContextMenu.x = setXPosition()
|
||||||
|
}
|
||||||
|
|
||||||
signal shouldCloseParentPopup
|
signal shouldCloseParentPopup
|
||||||
|
|
||||||
function show(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, emojiReactionsModel) {
|
function show(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, emojiReactionsModel) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ ScrollView {
|
||||||
StatusImageModal {
|
StatusImageModal {
|
||||||
id: imagePopup
|
id: imagePopup
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.close()
|
close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ Item {
|
||||||
property url source
|
property url source
|
||||||
property bool playing: applicationWindow.active
|
property bool playing: applicationWindow.active
|
||||||
property bool isAnimated: !!source && source.toString().endsWith('.gif')
|
property bool isAnimated: !!source && source.toString().endsWith('.gif')
|
||||||
signal clicked(var image, var button)
|
signal clicked(var image, var mouse)
|
||||||
property var container
|
property var container
|
||||||
property alias imageAlias: imageMessage
|
property alias imageAlias: imageMessage
|
||||||
property bool allCornersRounded: false
|
property bool allCornersRounded: false
|
||||||
|
@ -113,7 +113,7 @@ Item {
|
||||||
imageContainer.playing = !imageContainer.playing
|
imageContainer.playing = !imageContainer.playing
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
imageContainer.clicked(imageMessage, mouse.button)
|
imageContainer.clicked(imageMessage, mouse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue