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
|
2022-11-22 11:25:39 +00:00
|
|
|
import QtGraphicalEffects 1.14
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
import StatusQ.Core 0.1
|
2023-02-15 11:12:12 +00:00
|
|
|
import StatusQ.Core.Theme 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
|
2023-03-24 09:48:05 +00:00
|
|
|
property string chatId
|
|
|
|
|
2023-03-27 16:55:26 +00:00
|
|
|
property bool isPinActionAvaliable: true
|
2023-03-24 09:48:05 +00:00
|
|
|
|
2023-03-27 16:55:26 +00:00
|
|
|
function updatePinActionAvaliable() {
|
|
|
|
const contactDetails = chatId ? Utils.getContactDetailsAsJson(chatId, false) : null
|
|
|
|
isPinActionAvaliable = contactDetails ? contactDetails.isContact : true
|
2023-03-24 09:48:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.store.contactsStore.myContactsModel
|
|
|
|
|
|
|
|
function onItemChanged(pubKey) {
|
|
|
|
if (chatId === pubKey) {
|
2023-03-27 16:55:26 +00:00
|
|
|
updatePinActionAvaliable()
|
2023-03-24 09:48:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-27 16:55:26 +00:00
|
|
|
Component.onCompleted: updatePinActionAvaliable()
|
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")
|
2022-11-22 11:25:39 +00:00
|
|
|
subtitle: root.messageToPin ? qsTr("Unpin a previous message first")
|
|
|
|
: qsTr("%n message(s)", "", pinnedMessageListView.count)
|
2021-05-25 19:34:46 +00:00
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
contentItem: ColumnLayout {
|
2022-11-22 11:25:39 +00:00
|
|
|
id: column
|
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
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
|
2022-09-30 14:36:49 +00:00
|
|
|
responseToMessageWithId: model.responseToMessageWithId
|
2021-12-17 12:53:10 +00:00
|
|
|
senderId: model.senderId
|
|
|
|
senderDisplayName: model.senderDisplayName
|
2022-09-14 07:35:26 +00:00
|
|
|
senderOptionalName: model.senderOptionalName
|
|
|
|
senderIsEnsVerified: model.senderEnsVerified
|
2022-09-21 23:55:01 +00:00
|
|
|
senderIsAdded: model.senderIsAdded
|
2021-12-17 12:53:10 +00:00
|
|
|
senderIcon: model.senderIcon
|
2023-01-10 11:29:24 +00:00
|
|
|
senderColorHash: model.senderColorHash
|
2022-09-30 14:36:49 +00:00
|
|
|
senderTrustStatus: model.senderTrustStatus
|
2021-12-17 12:53:10 +00:00
|
|
|
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
|
2023-02-15 11:12:12 +00:00
|
|
|
sticker: model.sticker
|
|
|
|
stickerPack: model.stickerPack
|
2022-01-25 12:56:53 +00:00
|
|
|
linkUrls: model.links
|
2022-02-09 00:04:49 +00:00
|
|
|
transactionParams: model.transactionParameters
|
2023-01-10 11:29:24 +00:00
|
|
|
quotedMessageText: model.quotedMessageParsedText
|
|
|
|
quotedMessageFrom: model.quotedMessageFrom
|
|
|
|
quotedMessageContentType: model.quotedMessageContentType
|
|
|
|
quotedMessageDeleted: model.quotedMessageDeleted
|
|
|
|
quotedMessageAuthorDetailsName: model.quotedMessageAuthorName
|
|
|
|
quotedMessageAuthorDetailsDisplayName: model.quotedMessageAuthorDisplayName
|
|
|
|
quotedMessageAuthorDetailsThumbnailImage: model.quotedMessageAuthorThumbnailImage
|
|
|
|
quotedMessageAuthorDetailsEnsVerified: model.quotedMessageAuthorEnsVerified
|
|
|
|
quotedMessageAuthorDetailsIsContact: model.quotedMessageAuthorIsContact
|
|
|
|
quotedMessageAuthorDetailsColorHash: model.quotedMessageAuthorColorHash
|
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
|
2023-03-24 09:48:05 +00:00
|
|
|
prevMessageAsJsonObj: root.messageStore ? root.messageStore.getMessageByIndexAsJson(index - 1) : {}
|
2021-12-17 12:53:10 +00:00
|
|
|
nextMessageIndex: index + 1
|
2023-03-24 09:48:05 +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-12-26 16:33:27 +00:00
|
|
|
shouldRepeatHeader: true
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
2023-02-15 11:12:12 +00:00
|
|
|
id: mouseArea
|
2021-07-26 17:27:09 +00:00
|
|
|
anchors.fill: parent
|
2023-02-15 11:12:12 +00:00
|
|
|
hoverEnabled: true
|
2021-07-26 17:27:09 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
z: 55
|
2022-09-14 22:17:55 +00:00
|
|
|
onClicked: {
|
2023-02-01 17:47:30 +00:00
|
|
|
if (!!root.messageToPin) {
|
|
|
|
if (!radio.checked)
|
|
|
|
radio.checked = true
|
|
|
|
} else {
|
|
|
|
root.close()
|
|
|
|
root.messageStore.messageModule.jumpToMessage(model.id)
|
|
|
|
}
|
2022-09-14 22:17:55 +00:00
|
|
|
}
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
2023-02-15 11:12:12 +00:00
|
|
|
StatusFlatRoundButton {
|
|
|
|
id: unpinButton
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.bigPadding
|
|
|
|
z: mouseArea.z + 1
|
|
|
|
width: 32
|
|
|
|
height: 32
|
2023-03-27 16:55:26 +00:00
|
|
|
visible: root.isPinActionAvaliable && !root.messageToPin && (hovered || mouseArea.containsMouse)
|
2023-02-15 11:12:12 +00:00
|
|
|
icon.name: "unpin"
|
|
|
|
tooltip.text: qsTr("Unpin")
|
|
|
|
color: hovered ? Theme.palette.primaryColor2 : Theme.palette.indirectColor1
|
|
|
|
onClicked: {
|
|
|
|
root.messageStore.unpinMessage(model.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
StatusRadioButton {
|
2021-07-26 17:27:09 +00:00
|
|
|
id: radio
|
2023-02-15 11:12:12 +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
|
|
|
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
|
|
|
|
|
|
|
onUnpinMessage: {
|
2022-09-30 14:36:49 +00:00
|
|
|
root.messageStore.unpinMessage(messageId)
|
2022-01-05 15:50:03 +00:00
|
|
|
}
|
2022-09-19 08:40:02 +00:00
|
|
|
|
|
|
|
onJumpToMessage: {
|
2022-10-11 10:22:18 +00:00
|
|
|
root.messageStore.messageModule.jumpToMessage(messageId)
|
2022-09-19 08:40:02 +00:00
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
2022-11-22 11:25:39 +00:00
|
|
|
|
2023-02-15 11:12:12 +00:00
|
|
|
layer.enabled: root.visible && !root.messageToPin
|
2022-11-22 11:25:39 +00:00
|
|
|
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 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
|
|
|
}
|
|
|
|
}
|