fix(@desktop/pinned): actions to unpin and jump to the message

This commit is contained in:
Andrei Smirnov 2021-07-22 10:47:15 +03:00 committed by Iuri Matias
parent fa94d3d2db
commit 0675f013af
4 changed files with 43 additions and 2 deletions

View File

@ -91,6 +91,9 @@ Rectangle {
onClicked: { onClicked: {
SelectedMessage.set(messageId, fromAuthor); SelectedMessage.set(messageId, fromAuthor);
showReplyArea() showReplyArea()
if (messageContextMenu.closeParentPopup) {
messageContextMenu.closeParentPopup()
}
} }
onHoveredChanged: { onHoveredChanged: {
buttonsContainer.hoverChanged(this.hovered) buttonsContainer.hoverChanged(this.hovered)

View File

@ -10,6 +10,7 @@ import "./"
PopupMenu { PopupMenu {
id: messageContextMenu id: messageContextMenu
width: messageContextMenu.isProfile ? profileHeader.width : emojiContainer.width width: messageContextMenu.isProfile ? profileHeader.width : emojiContainer.width
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
property string messageId property string messageId
property bool isProfile: false property bool isProfile: false
@ -17,6 +18,7 @@ PopupMenu {
property bool emojiOnly: false property bool emojiOnly: false
property bool hideEmojiPicker: false property bool hideEmojiPicker: false
property bool pinnedMessage: false property bool pinnedMessage: false
property bool showJumpTo: false
property bool isText: false property bool isText: false
property bool isCurrentUser: false property bool isCurrentUser: false
property string linkUrls: "" property string linkUrls: ""
@ -30,6 +32,8 @@ PopupMenu {
property var onClickEdit: function(){} property var onClickEdit: function(){}
property var reactionModel property var reactionModel
signal closeParentPopup
subMenuIcons: [{ subMenuIcons: [{
source: Qt.resolvedUrl("../../../../shared/img/copy-to-clipboard-icon"), source: Qt.resolvedUrl("../../../../shared/img/copy-to-clipboard-icon"),
width: 16, width: 16,
@ -53,7 +57,7 @@ PopupMenu {
const numLinkUrls = messageContextMenu.linkUrls.split(" ").length const numLinkUrls = messageContextMenu.linkUrls.split(" ").length
copyLinkMenu.enabled = numLinkUrls > 1 copyLinkMenu.enabled = numLinkUrls > 1
copyLinkAction.enabled = !!messageContextMenu.linkUrls && numLinkUrls === 1 && !emojiOnly && !messageContextMenu.isProfile copyLinkAction.enabled = !!messageContextMenu.linkUrls && numLinkUrls === 1 && !emojiOnly && !messageContextMenu.isProfile
popup(); popup()
} }
Item { Item {
@ -265,6 +269,7 @@ PopupMenu {
} else { } else {
showReplyArea() showReplyArea()
} }
messageContextMenu.closeParentPopup()
messageContextMenu.close() messageContextMenu.close()
} }
icon.source: "../../../img/messageActive.svg" icon.source: "../../../img/messageActive.svg"
@ -272,4 +277,17 @@ PopupMenu {
icon.height: 16 icon.height: 16
enabled: !isSticker && !emojiOnly enabled: !isSticker && !emojiOnly
} }
Action {
text: qsTr("Jump to")
onTriggered: {
positionAtMessage(messageContextMenu.messageId)
messageContextMenu.closeParentPopup()
messageContextMenu.close()
}
icon.source: "../../../img/arrow-up.svg"
icon.width: 16
icon.height: 16
enabled: messageContextMenu.pinnedMessage && messageContextMenu.showJumpTo
}
} }

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import "../../../../imports" import "../../../../imports"
import "../../../../shared" import "../../../../shared"
import "../../../../shared/status" import "../../../../shared/status"
import "../data"
import "../ChatColumn" import "../ChatColumn"
ModalPopup { ModalPopup {
@ -70,7 +71,13 @@ ModalPopup {
anchors.topMargin: -Style.current.halfPadding anchors.topMargin: -Style.current.halfPadding
clip: true clip: true
function closePopup() {
popup.close()
}
delegate: Message { delegate: Message {
id: messageItem
property var view: ListView.view
fromAuthor: model.fromAuthor fromAuthor: model.fromAuthor
chatId: model.chatId chatId: model.chatId
userName: model.userName userName: model.userName
@ -96,8 +103,18 @@ ModalPopup {
pinnedMessage: true pinnedMessage: true
pinnedBy: model.pinnedBy pinnedBy: model.pinnedBy
forceHoverHandler: true forceHoverHandler: true
activityCenterMessage: false
isEdited: model.isEdited isEdited: model.isEdited
showEdit: false showEdit: false
messageContextMenu: MessageContextMenu {
showJumpTo: true
pinnedMessage: true
reactionModel: EmojiReactions { }
onCloseParentPopup: {
messageItem.view.closePopup()
}
}
} }
} }
} }

3
ui/app/img/arrow-up.svg Normal file
View File

@ -0,0 +1,3 @@
<svg width="10" height="12" viewBox="0 0 10 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.35355 5.02055C1.15829 5.21581 0.841709 5.21581 0.646447 5.02055C0.451184 4.82528 0.451184 4.5087 0.646447 4.31344L4.64645 0.313439C4.84171 0.118177 5.15829 0.118177 5.35355 0.313439L9.35355 4.31344C9.54882 4.5087 9.54882 4.82528 9.35355 5.02055C9.15829 5.21581 8.84171 5.21581 8.64645 5.02055L6.06904 2.44313C5.85905 2.23315 5.5 2.38187 5.5 2.67884V11.3337C5.5 11.6098 5.27614 11.8337 5 11.8337C4.72386 11.8337 4.5 11.6098 4.5 11.3337L4.5 2.67884C4.5 2.38187 4.14095 2.23315 3.93096 2.44313L1.35355 5.02055Z" fill="#4360DF"/>
</svg>

After

Width:  |  Height:  |  Size: 641 B