2022-09-14 22:17:55 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtQml.Models 2.14
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
import StatusQ.Core 0.1
|
2022-09-14 22:17:55 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2022-07-14 11:03:36 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.views.chat 1.0
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
StatusDialog {
|
|
|
|
id: root
|
2021-12-17 12:53:10 +00:00
|
|
|
|
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
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
width: 800
|
|
|
|
height: 428
|
|
|
|
padding: 0
|
2021-05-25 19:38:18 +00:00
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
title: root.messageToPin ? qsTr("Pin limit reached") : qsTr("Pinned messages")
|
2021-05-25 19:34:46 +00:00
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
header: StatusDialogHeader {
|
|
|
|
visible: root.title
|
|
|
|
headline.title: root.title
|
|
|
|
headline.subtitle: root.messageToPin ? qsTr("Unpin a previous message first")
|
|
|
|
: qsTr("%n message(s)", "", pinnedMessageListView.count)
|
|
|
|
actions.closeButton.onClicked: root.close()
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
contentItem: ColumnLayout {
|
|
|
|
StatusBaseText {
|
2021-05-25 19:38:18 +00:00
|
|
|
visible: pinnedMessageListView.count === 0
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Pinned messages will appear here.")
|
2022-09-14 22:17:55 +00:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2021-05-25 19:38:18 +00:00
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
|
2021-07-26 17:27:09 +00:00
|
|
|
ButtonGroup {
|
|
|
|
id: pinButtonGroup
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2021-05-25 19:38:18 +00:00
|
|
|
id: pinnedMessageListView
|
2022-09-14 22:17:55 +00:00
|
|
|
model: root.pinnedMessagesModel
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: count
|
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
|
2022-07-05 10:12:27 +00:00
|
|
|
|
|
|
|
width: ListView.view.width
|
2021-07-26 17:27:09 +00:00
|
|
|
height: messageItem.height
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
MessageView {
|
2021-07-26 17:27:09 +00:00
|
|
|
id: messageItem
|
2022-07-05 10:12:27 +00:00
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
rootStore: root.store
|
|
|
|
messageStore: root.messageStore
|
2021-12-17 12:53:10 +00:00
|
|
|
messageContextMenu: msgContextMenu
|
|
|
|
|
|
|
|
messageId: model.id
|
|
|
|
responseToMessageWithId: model.responseToMessageWithId
|
|
|
|
senderId: model.senderId
|
|
|
|
senderDisplayName: model.senderDisplayName
|
|
|
|
senderLocalName: model.senderLocalName
|
2022-07-05 10:12:27 +00:00
|
|
|
senderEnsName: model.senderEnsVerified ? model.senderDisplayName : ""
|
2021-12-17 12:53:10 +00:00
|
|
|
senderIcon: model.senderIcon
|
|
|
|
amISender: model.amISender
|
2022-07-05 10:12:27 +00:00
|
|
|
messageText: model.messageText
|
2021-12-17 12:53:10 +00:00
|
|
|
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-06-28 18:11:18 +00:00
|
|
|
senderTrustStatus: model.senderTrustStatus
|
2022-01-25 12:56:53 +00:00
|
|
|
linkUrls: model.links
|
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
|
2022-09-14 22:17:55 +00:00
|
|
|
prevMessageAsJsonObj: root.messageStore? root.messageStore.getMessageByIndexAsJson(index - 1) : {}
|
2021-12-17 12:53:10 +00:00
|
|
|
nextMessageIndex: index + 1
|
2022-09-14 22:17:55 +00:00
|
|
|
nextMessageAsJsonObj: root.messageStore? root.messageStore.getMessageByIndexAsJson(index + 1) : {}
|
2021-12-17 12:53:10 +00:00
|
|
|
|
|
|
|
// Additional params
|
2022-07-05 10:12:27 +00:00
|
|
|
isInPinnedPopup: true
|
2022-09-14 22:17:55 +00:00
|
|
|
disableHover: !!root.messageToPin
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2022-09-16 09:41:30 +00:00
|
|
|
enabled: !!root.messageToPin
|
2021-07-26 17:27:09 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
z: 55
|
2022-09-14 22:17:55 +00:00
|
|
|
onClicked: {
|
|
|
|
if (!radio.checked)
|
|
|
|
radio.checked = true
|
|
|
|
}
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
StatusRadioButton {
|
2021-07-26 17:27:09 +00:00
|
|
|
id: radio
|
2022-09-14 22:17:55 +00:00
|
|
|
visible: !!root.messageToPin
|
2021-07-26 17:27:09 +00:00
|
|
|
anchors.right: parent.right
|
2022-09-14 22:17:55 +00:00
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2021-07-26 17:27:09 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
ButtonGroup.group: pinButtonGroup
|
2022-09-14 22:17:55 +00:00
|
|
|
onCheckedChanged: { // NB this should be `onToggled` but MouseArea above handles the whole delegate
|
|
|
|
root.messageToUnpin = checked ? model.id : ""
|
2021-07-22 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-25 19:38:18 +00:00
|
|
|
}
|
2022-02-09 09:43:23 +00:00
|
|
|
}
|
2022-09-14 22:17:55 +00:00
|
|
|
|
2021-11-02 19:58:48 +00:00
|
|
|
MessageContextMenuView {
|
|
|
|
id: msgContextMenu
|
2022-09-14 22:17:55 +00:00
|
|
|
reactionModel: root.emojiReactionsModel
|
|
|
|
store: root.store
|
2021-11-02 19:58:48 +00:00
|
|
|
pinnedPopup: true
|
|
|
|
pinnedMessage: true
|
|
|
|
onShouldCloseParentPopup: {
|
2022-09-14 22:17:55 +00:00
|
|
|
root.close()
|
2021-11-02 19:58:48 +00:00
|
|
|
}
|
2021-12-17 12:53:10 +00:00
|
|
|
|
|
|
|
onPinMessage: {
|
2022-09-14 22:17:55 +00:00
|
|
|
root.messageStore.pinMessage(messageId)
|
2021-12-17 12:53:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onUnpinMessage: {
|
2022-09-14 22:17:55 +00:00
|
|
|
root.messageStore.unpinMessage(messageId)
|
2021-12-17 12:53:10 +00:00
|
|
|
}
|
2021-12-20 14:21:35 +00:00
|
|
|
|
|
|
|
onToggleReaction: {
|
2022-09-14 22:17:55 +00:00
|
|
|
root.messageStore.toggleReaction(messageId, emojiId)
|
2021-12-20 14:21:35 +00:00
|
|
|
}
|
2022-01-05 15:50:03 +00:00
|
|
|
|
|
|
|
onOpenProfileClicked: {
|
2022-06-20 14:48:38 +00:00
|
|
|
Global.openProfilePopup(publicKey, null, state)
|
2022-01-05 15:50:03 +00:00
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
footer: StatusDialogFooter {
|
|
|
|
id: footer
|
|
|
|
visible: !!root.messageToPin
|
|
|
|
rightButtons: ObjectModel {
|
|
|
|
StatusButton {
|
|
|
|
visible: footer.visible
|
|
|
|
enabled: !!root.messageToUnpin && pinButtonGroup.checkedButton
|
|
|
|
text: qsTr("Unpin selected message and pin new message")
|
|
|
|
onClicked: {
|
|
|
|
root.messageStore.unpinMessage(root.messageToUnpin)
|
|
|
|
root.messageToUnpin = ""
|
|
|
|
root.messageStore.pinMessage(root.messageToPin)
|
|
|
|
root.messageToPin = ""
|
|
|
|
root.close()
|
|
|
|
}
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
|
|
|
}
|