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
|
2023-05-19 16:07:50 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2022-09-14 22:17:55 +00:00
|
|
|
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
|
2024-10-02 20:47:14 +00:00
|
|
|
import shared.stores 1.0 as SharedStores
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0
|
|
|
|
|
2022-09-14 22:17:55 +00:00
|
|
|
StatusDialog {
|
|
|
|
id: root
|
2021-12-17 12:53:10 +00:00
|
|
|
|
2024-10-02 20:47:14 +00:00
|
|
|
property SharedStores.RootStore sharedStore
|
2024-05-22 08:13:39 +00:00
|
|
|
property RootStore store
|
|
|
|
property MessageStore 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-05-09 10:31:50 +00:00
|
|
|
readonly property var contactDetails: store ? store.oneToOneChatContact : null
|
|
|
|
readonly property bool isPinActionAvaliable: contactDetails ? contactDetails.isContact : true
|
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
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
function jumpToMessage(messageId) {
|
|
|
|
root.close()
|
|
|
|
root.messageStore.messageModule.jumpToMessage(messageId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2024-10-02 20:47:14 +00:00
|
|
|
sharedRootStore: root.sharedStore
|
2022-09-14 22:17:55 +00:00
|
|
|
rootStore: root.store
|
|
|
|
messageStore: root.messageStore
|
2021-12-17 12:53:10 +00:00
|
|
|
|
|
|
|
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
|
2023-07-26 14:09:36 +00:00
|
|
|
linkPreviewModel: model.linkPreviewModel
|
2023-08-22 15:46:26 +00:00
|
|
|
links: 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
|
2024-01-05 15:34:20 +00:00
|
|
|
bridgeName: model.bridgeName
|
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
|
2023-05-19 16:07:50 +00:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onClicked: (mouse) => {
|
|
|
|
switch (mouse.button) {
|
|
|
|
case Qt.RightButton:
|
|
|
|
Global.openMenu(pinnedPopupMessageContextMenuComponent, this, {
|
|
|
|
messageId: messageItem.messageId,
|
|
|
|
})
|
|
|
|
break
|
|
|
|
case Qt.LeftButton:
|
|
|
|
if (!!root.messageToPin) {
|
|
|
|
if (!radio.checked)
|
|
|
|
radio.checked = true
|
|
|
|
} else {
|
|
|
|
d.jumpToMessage(model.id)
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2022-09-14 22:17:55 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
Component {
|
|
|
|
id: pinnedPopupMessageContextMenuComponent
|
2021-12-17 12:53:10 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
StatusMenu {
|
|
|
|
id: messageContextMenu
|
2022-09-19 08:40:02 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
property string messageId
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: qsTr("Unpin")
|
|
|
|
icon.name: "unpin"
|
|
|
|
onTriggered: {
|
|
|
|
root.messageStore.unpinMessage(messageContextMenu.messageId)
|
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusAction {
|
|
|
|
text: qsTr("Jump to")
|
|
|
|
icon.name: "arrow-up"
|
|
|
|
onTriggered: {
|
|
|
|
d.jumpToMessage(messageContextMenu.messageId)
|
|
|
|
close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
messageItem.setMessageActive(model.id, true)
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
messageItem.setMessageActive(model.id, false)
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|