2022-09-15 00:17:55 +02:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtQml.Models 2.14
|
2022-11-22 12:25:39 +01:00
|
|
|
import QtGraphicalEffects 1.14
|
2021-09-28 18:04:06 +03:00
|
|
|
|
2022-07-14 14:03:36 +03:00
|
|
|
import StatusQ.Core 0.1
|
2022-09-15 00:17:55 +02:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2022-07-14 14:03:36 +03:00
|
|
|
|
2021-09-28 18:04:06 +03:00
|
|
|
import utils 1.0
|
2021-10-28 23:23:30 +03:00
|
|
|
import shared.views.chat 1.0
|
2021-10-01 18:58:36 +03:00
|
|
|
|
2022-09-15 00:17:55 +02:00
|
|
|
StatusDialog {
|
|
|
|
id: root
|
2021-12-17 13:53:10 +01:00
|
|
|
|
2022-01-19 10:59:08 -05:00
|
|
|
property var store
|
2021-10-01 18:58:36 +03:00
|
|
|
property var messageStore
|
2021-12-17 13:53:10 +01: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 13:27:09 -04:00
|
|
|
property string messageToPin
|
|
|
|
property string messageToUnpin
|
2022-01-05 16:50:03 +01:00
|
|
|
property var emojiReactionsModel
|
2021-07-26 13:27:09 -04:00
|
|
|
|
2022-09-15 00:17:55 +02:00
|
|
|
width: 800
|
|
|
|
height: 428
|
|
|
|
padding: 0
|
2021-05-25 15:38:18 -04:00
|
|
|
|
2022-09-15 00:17:55 +02:00
|
|
|
title: root.messageToPin ? qsTr("Pin limit reached") : qsTr("Pinned messages")
|
2022-11-22 12:25:39 +01:00
|
|
|
subtitle: root.messageToPin ? qsTr("Unpin a previous message first")
|
|
|
|
: qsTr("%n message(s)", "", pinnedMessageListView.count)
|
2021-05-25 15:34:46 -04:00
|
|
|
|
2022-09-15 00:17:55 +02:00
|
|
|
contentItem: ColumnLayout {
|
2022-11-22 12:25:39 +01:00
|
|
|
id: column
|
|
|
|
|
2022-09-15 00:17:55 +02:00
|
|
|
StatusBaseText {
|
2021-05-25 15:38:18 -04:00
|
|
|
visible: pinnedMessageListView.count === 0
|
2022-04-04 13:26:30 +02:00
|
|
|
text: qsTr("Pinned messages will appear here.")
|
2022-09-15 00:17:55 +02:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2021-05-25 15:38:18 -04:00
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
|
2021-07-26 13:27:09 -04:00
|
|
|
ButtonGroup {
|
|
|
|
id: pinButtonGroup
|
|
|
|
}
|
|
|
|
|
2022-07-14 14:03:36 +03:00
|
|
|
StatusListView {
|
2021-05-25 15:38:18 -04:00
|
|
|
id: pinnedMessageListView
|
2022-09-15 00:17:55 +02:00
|
|
|
model: root.pinnedMessagesModel
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: count
|
2021-12-17 13:53:10 +01:00
|
|
|
|
2021-07-26 13:27:09 -04:00
|
|
|
delegate: Item {
|
2021-10-01 18:58:36 +03:00
|
|
|
id: messageDelegate
|
2022-07-05 14:12:27 +04:00
|
|
|
|
|
|
|
width: ListView.view.width
|
2021-07-26 13:27:09 -04:00
|
|
|
height: messageItem.height
|
|
|
|
|
2021-10-01 18:58:36 +03:00
|
|
|
MessageView {
|
2021-07-26 13:27:09 -04:00
|
|
|
id: messageItem
|
2022-07-05 14:12:27 +04:00
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
2022-09-15 00:17:55 +02:00
|
|
|
rootStore: root.store
|
|
|
|
messageStore: root.messageStore
|
2021-12-17 13:53:10 +01:00
|
|
|
messageContextMenu: msgContextMenu
|
|
|
|
|
|
|
|
messageId: model.id
|
2022-09-30 17:36:49 +03:00
|
|
|
responseToMessageWithId: model.responseToMessageWithId
|
2021-12-17 13:53:10 +01:00
|
|
|
senderId: model.senderId
|
|
|
|
senderDisplayName: model.senderDisplayName
|
2022-09-14 09:35:26 +02:00
|
|
|
senderOptionalName: model.senderOptionalName
|
|
|
|
senderIsEnsVerified: model.senderEnsVerified
|
2022-09-22 01:55:01 +02:00
|
|
|
senderIsAdded: model.senderIsAdded
|
2021-12-17 13:53:10 +01:00
|
|
|
senderIcon: model.senderIcon
|
2022-09-30 17:36:49 +03:00
|
|
|
senderTrustStatus: model.senderTrustStatus
|
2021-12-17 13:53:10 +01:00
|
|
|
amISender: model.amISender
|
2022-07-05 14:12:27 +04:00
|
|
|
messageText: model.messageText
|
2021-12-17 13:53:10 +01:00
|
|
|
messageImage: model.messageImage
|
|
|
|
messageTimestamp: model.timestamp
|
|
|
|
messageOutgoingStatus: model.outgoingStatus
|
|
|
|
messageContentType: model.contentType
|
|
|
|
pinnedMessage: model.pinned
|
2022-01-05 16:50:03 +01:00
|
|
|
messagePinnedBy: model.pinnedBy
|
2022-01-25 13:56:53 +01:00
|
|
|
linkUrls: model.links
|
2022-02-09 01:04:49 +01:00
|
|
|
transactionParams: model.transactionParameters
|
2021-12-17 13:53:10 +01: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-15 00:17:55 +02:00
|
|
|
prevMessageAsJsonObj: root.messageStore? root.messageStore.getMessageByIndexAsJson(index - 1) : {}
|
2021-12-17 13:53:10 +01:00
|
|
|
nextMessageIndex: index + 1
|
2022-09-15 00:17:55 +02:00
|
|
|
nextMessageAsJsonObj: root.messageStore? root.messageStore.getMessageByIndexAsJson(index + 1) : {}
|
2021-12-17 13:53:10 +01:00
|
|
|
|
|
|
|
// Additional params
|
2022-07-05 14:12:27 +04:00
|
|
|
isInPinnedPopup: true
|
2022-09-15 00:17:55 +02:00
|
|
|
disableHover: !!root.messageToPin
|
2022-12-26 19:33:27 +03:00
|
|
|
shouldRepeatHeader: true
|
2021-07-26 13:27:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2022-09-16 11:41:30 +02:00
|
|
|
enabled: !!root.messageToPin
|
2021-07-26 13:27:09 -04:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
z: 55
|
2022-09-15 00:17:55 +02:00
|
|
|
onClicked: {
|
|
|
|
if (!radio.checked)
|
|
|
|
radio.checked = true
|
|
|
|
}
|
2021-07-26 13:27:09 -04:00
|
|
|
}
|
|
|
|
|
2022-09-15 00:17:55 +02:00
|
|
|
StatusRadioButton {
|
2021-07-26 13:27:09 -04:00
|
|
|
id: radio
|
2022-09-15 00:17:55 +02:00
|
|
|
visible: !!root.messageToPin
|
2021-07-26 13:27:09 -04:00
|
|
|
anchors.right: parent.right
|
2022-09-15 00:17:55 +02:00
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
2021-07-26 13:27:09 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
ButtonGroup.group: pinButtonGroup
|
2022-09-15 00:17:55 +02:00
|
|
|
onCheckedChanged: { // NB this should be `onToggled` but MouseArea above handles the whole delegate
|
|
|
|
root.messageToUnpin = checked ? model.id : ""
|
2021-07-22 10:47:15 +03:00
|
|
|
}
|
|
|
|
}
|
2021-05-25 15:38:18 -04:00
|
|
|
}
|
2022-02-09 10:43:23 +01:00
|
|
|
}
|
2022-09-15 00:17:55 +02:00
|
|
|
|
2021-11-02 20:58:48 +01:00
|
|
|
MessageContextMenuView {
|
|
|
|
id: msgContextMenu
|
2022-09-15 00:17:55 +02:00
|
|
|
reactionModel: root.emojiReactionsModel
|
|
|
|
store: root.store
|
2021-11-02 20:58:48 +01:00
|
|
|
pinnedPopup: true
|
|
|
|
pinnedMessage: true
|
|
|
|
onShouldCloseParentPopup: {
|
2022-09-15 00:17:55 +02:00
|
|
|
root.close()
|
2021-11-02 20:58:48 +01:00
|
|
|
}
|
2021-12-17 13:53:10 +01:00
|
|
|
|
|
|
|
onUnpinMessage: {
|
2022-09-30 17:36:49 +03:00
|
|
|
root.messageStore.unpinMessage(messageId)
|
2022-01-05 16:50:03 +01:00
|
|
|
}
|
2022-09-19 10:40:02 +02:00
|
|
|
|
|
|
|
onJumpToMessage: {
|
2022-10-11 12:22:18 +02:00
|
|
|
root.messageStore.messageModule.jumpToMessage(messageId)
|
2022-09-19 10:40:02 +02:00
|
|
|
}
|
2021-05-25 15:34:46 -04:00
|
|
|
}
|
2022-11-22 12:25:39 +01:00
|
|
|
|
|
|
|
layer.enabled: root.visible
|
|
|
|
layer.effect: OpacityMask {
|
|
|
|
maskSource: Rectangle {
|
|
|
|
width: column.width
|
|
|
|
height: column.height
|
|
|
|
radius: background.radius
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
width: parent.width
|
|
|
|
height: parent.radius
|
|
|
|
anchors.top: parent.top
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-25 15:34:46 -04:00
|
|
|
}
|
|
|
|
|
2022-09-15 00:17:55 +02: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 13:27:09 -04:00
|
|
|
}
|
|
|
|
}
|
2021-05-25 15:34:46 -04:00
|
|
|
}
|
|
|
|
}
|