2021-05-25 19:34:46 +00:00
|
|
|
import QtQuick 2.13
|
2021-07-26 17:27:09 +00:00
|
|
|
import QtQuick.Controls 2.3
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.views 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.views.chat 1.0
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
import "../controls"
|
|
|
|
import "../panels"
|
|
|
|
//TODO remove or make view?
|
|
|
|
import "../views"
|
2021-05-25 19:34:46 +00:00
|
|
|
|
2021-10-19 11:58:06 +00:00
|
|
|
import StatusQ.Controls 0.1 as StatusQControls
|
|
|
|
|
2021-10-14 11:33:34 +00:00
|
|
|
// TODO: replace with StatusMOdal
|
2021-05-25 19:34:46 +00:00
|
|
|
ModalPopup {
|
2021-12-17 12:53:10 +00:00
|
|
|
id: popup
|
|
|
|
|
2022-01-19 15:59:08 +00:00
|
|
|
property var store
|
2021-10-01 15:58:36 +00:00
|
|
|
property var messageStore
|
2021-12-17 12:53:10 +00:00
|
|
|
property var pinnedMessagesModel //this doesn't belong to the messageStore, it is a part of the ChatContentStore, but we didn't introduce it yet.
|
2021-07-26 17:27:09 +00:00
|
|
|
property string messageToPin
|
|
|
|
property string messageToUnpin
|
2022-01-05 15:50:03 +00:00
|
|
|
property var emojiReactionsModel
|
2021-07-26 17:27:09 +00:00
|
|
|
|
2021-05-25 19:34:46 +00:00
|
|
|
header: Item {
|
|
|
|
height: childrenRect.height
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: title
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Pin limit reached"
|
2021-12-17 12:53:10 +00:00
|
|
|
text: !!popup.messageToPin ? qsTrId("pin-limit-reached") :
|
2021-07-26 17:27:09 +00:00
|
|
|
//% "Pinned messages"
|
|
|
|
qsTrId("pinned-messages")
|
2021-05-25 19:34:46 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 17
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
2021-05-25 19:38:18 +00:00
|
|
|
property int nbMessages: pinnedMessageListView.count
|
|
|
|
|
2021-05-25 19:34:46 +00:00
|
|
|
id: nbPinnedMessages
|
2021-07-26 17:27:09 +00:00
|
|
|
text: {
|
2021-12-17 12:53:10 +00:00
|
|
|
if (!!popup.messageToPin) {
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Unpin a previous message first"
|
|
|
|
return qsTrId("unpin-a-previous-message-first")
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//% "%1 messages"
|
|
|
|
return nbMessages > 1 ? qsTrId("-1-messages").arg(nbMessages) :
|
|
|
|
//% "%1 message"
|
|
|
|
qsTrId("-1-message").arg(nbMessages)
|
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: title.bottom
|
|
|
|
anchors.topMargin: 2
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
anchors.top: nbPinnedMessages.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
Item {
|
|
|
|
anchors.fill: parent
|
2021-05-25 19:34:46 +00:00
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
StyledText {
|
|
|
|
visible: pinnedMessageListView.count === 0
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Pinned messages will appear here."
|
|
|
|
text: qsTrId("pinned-messages-will-appear-here-")
|
2021-05-25 19:38:18 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
|
2021-07-26 17:27:09 +00:00
|
|
|
ButtonGroup {
|
|
|
|
id: pinButtonGroup
|
|
|
|
}
|
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
ListView {
|
|
|
|
id: pinnedMessageListView
|
2021-12-17 12:53:10 +00:00
|
|
|
model: popup.pinnedMessagesModel
|
2021-05-25 19:38:18 +00:00
|
|
|
height: parent.height
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
topMargin: Style.current.halfPadding
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: -Style.current.halfPadding
|
|
|
|
clip: true
|
2021-12-17 12:53:10 +00:00
|
|
|
|
2021-07-26 17:27:09 +00:00
|
|
|
delegate: Item {
|
2021-10-01 15:58:36 +00:00
|
|
|
id: messageDelegate
|
2021-08-16 12:35:24 +00:00
|
|
|
property var listView: ListView.view
|
2021-07-26 17:27:09 +00:00
|
|
|
width: parent.width
|
|
|
|
height: messageItem.height
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
MessageView {
|
2021-07-26 17:27:09 +00:00
|
|
|
id: messageItem
|
2022-02-11 21:41:34 +00:00
|
|
|
store: popup.store
|
2021-12-17 12:53:10 +00:00
|
|
|
messageStore: popup.messageStore
|
|
|
|
messageContextMenu: msgContextMenu
|
|
|
|
|
|
|
|
messageId: model.id
|
|
|
|
responseToMessageWithId: model.responseToMessageWithId
|
|
|
|
senderId: model.senderId
|
|
|
|
senderDisplayName: model.senderDisplayName
|
|
|
|
senderLocalName: model.senderLocalName
|
|
|
|
senderIcon: model.senderIcon
|
|
|
|
amISender: model.amISender
|
|
|
|
message: model.messageText
|
|
|
|
messageImage: model.messageImage
|
|
|
|
messageTimestamp: model.timestamp
|
|
|
|
messageOutgoingStatus: model.outgoingStatus
|
|
|
|
messageContentType: model.contentType
|
|
|
|
pinnedMessage: model.pinned
|
2022-01-05 15:50:03 +00:00
|
|
|
messagePinnedBy: model.pinnedBy
|
2021-12-20 14:21:35 +00:00
|
|
|
reactionsModel: model.reactions
|
2022-01-25 12:56:53 +00:00
|
|
|
linkUrls: model.links
|
2022-02-01 18:45:28 +00:00
|
|
|
isInPinnedPopup: true
|
2022-02-09 00:04:49 +00:00
|
|
|
transactionParams: model.transactionParameters
|
2021-12-17 12:53:10 +00:00
|
|
|
|
|
|
|
// This is possible since we have all data loaded before we load qml.
|
|
|
|
// When we fetch messages to fulfill a gap we have to set them at once.
|
|
|
|
prevMessageIndex: index - 1
|
|
|
|
prevMessageAsJsonObj: popup.messageStore? popup.messageStore.getMessageByIndexAsJson(index - 1) : {}
|
|
|
|
nextMessageIndex: index + 1
|
2022-01-05 15:50:03 +00:00
|
|
|
nextMessageAsJsonObj: popup.messageStore? popup.messageStore.getMessageByIndexAsJson(index + 1) : {}
|
2021-12-17 12:53:10 +00:00
|
|
|
|
|
|
|
// Additional params
|
|
|
|
forceHoverHandler: !popup.messageToPin
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2021-12-17 12:53:10 +00:00
|
|
|
enabled: !!popup.messageToPin
|
2021-07-26 17:27:09 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
z: 55
|
|
|
|
onClicked: radio.toggle()
|
|
|
|
}
|
|
|
|
|
2021-10-25 12:30:23 +00:00
|
|
|
StatusQControls.StatusRadioButton {
|
2021-07-26 17:27:09 +00:00
|
|
|
id: radio
|
2021-12-17 12:53:10 +00:00
|
|
|
visible: !!popup.messageToPin
|
2021-07-26 17:27:09 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 18
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
ButtonGroup.group: pinButtonGroup
|
|
|
|
function toggle() {
|
|
|
|
radio.checked = !radio.checked
|
|
|
|
if (radio.checked) {
|
2021-12-17 12:53:10 +00:00
|
|
|
popup.messageToUnpin = model.id
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
2021-07-22 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-25 19:38:18 +00:00
|
|
|
}
|
2022-02-09 09:43:23 +00:00
|
|
|
}
|
2021-11-02 19:58:48 +00:00
|
|
|
MessageContextMenuView {
|
|
|
|
id: msgContextMenu
|
2022-01-05 15:50:03 +00:00
|
|
|
reactionModel: popup.emojiReactionsModel
|
2022-01-19 15:59:08 +00:00
|
|
|
store: popup.store
|
2021-11-02 19:58:48 +00:00
|
|
|
pinnedPopup: true
|
|
|
|
pinnedMessage: true
|
|
|
|
onShouldCloseParentPopup: {
|
|
|
|
popup.close()
|
|
|
|
}
|
2021-12-17 12:53:10 +00:00
|
|
|
|
|
|
|
onPinMessage: {
|
|
|
|
popup.messageStore.pinMessage(messageId)
|
|
|
|
}
|
|
|
|
|
|
|
|
onUnpinMessage: {
|
|
|
|
popup.messageStore.unpinMessage(messageId)
|
|
|
|
}
|
2021-12-20 14:21:35 +00:00
|
|
|
|
|
|
|
onToggleReaction: {
|
|
|
|
popup.messageStore.toggleReaction(messageId, emojiId)
|
|
|
|
}
|
2022-01-05 15:50:03 +00:00
|
|
|
|
|
|
|
onOpenProfileClicked: {
|
|
|
|
Global.openProfilePopup(publicKey)
|
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
|
2021-07-26 17:27:09 +00:00
|
|
|
footer: Item {
|
|
|
|
width: parent.width
|
2021-09-23 10:07:07 +00:00
|
|
|
height: btnUnpin.height
|
2021-07-26 17:27:09 +00:00
|
|
|
|
2021-10-19 11:58:06 +00:00
|
|
|
StatusQControls.StatusButton {
|
2021-07-26 17:27:09 +00:00
|
|
|
id: btnUnpin
|
2021-12-17 12:53:10 +00:00
|
|
|
visible: !!popup.messageToPin
|
|
|
|
enabled: !!popup.messageToUnpin
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Unpin"
|
|
|
|
text: qsTrId("unpin")
|
2021-10-25 12:30:23 +00:00
|
|
|
type: StatusQControls.StatusBaseButton.Type.Danger
|
2021-07-26 17:27:09 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
onClicked: {
|
2021-12-17 12:53:10 +00:00
|
|
|
popup.messageStore.unpinMessage(popup.messageToUnpin)
|
|
|
|
popup.messageToUnpin = ""
|
2022-02-03 15:57:38 +00:00
|
|
|
popup.messageStore.pinMessage(popup.messageToPin)
|
2021-12-17 12:53:10 +00:00
|
|
|
popup.messageToPin = ""
|
2021-07-26 17:27:09 +00:00
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
|
|
|
}
|