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-10-01 15:58:36 +00:00
|
|
|
property var rootStore
|
|
|
|
property var messageStore
|
2021-12-09 16:25:38 +00:00
|
|
|
property var chatSectionModule
|
2021-07-26 17:27:09 +00:00
|
|
|
property bool userCanPin: {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
return false
|
|
|
|
// switch (popup.rootStore.chatsModelInst.channelView.activeChannel.chatType) {
|
|
|
|
// case Constants.chatType.publicChat: return false
|
|
|
|
// case Constants.chatType.profile: return false
|
|
|
|
// case Constants.chatType.oneToOne: return true
|
|
|
|
// case Constants.chatType.privateGroupChat: return popup.rootStore.chatsModelInst.channelView.activeChannel.isAdmin(userProfile.pubKey)
|
|
|
|
// case Constants.chatType.communityChat: return popup.rootStore.chatsModelInst.communities.activeCommunity.admin
|
|
|
|
// default: return false
|
|
|
|
// }
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
|
|
|
property string messageToPin
|
|
|
|
property string messageToUnpin
|
|
|
|
|
2021-05-25 19:34:46 +00:00
|
|
|
id: popup
|
|
|
|
|
|
|
|
header: Item {
|
|
|
|
height: childrenRect.height
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: title
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Pin limit reached"
|
|
|
|
text: !!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: {
|
|
|
|
if (!!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-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// model: popup.rootStore.chatsModelInst.messageView.pinnedMessagesList
|
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-08-16 12:35:24 +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
|
2021-12-09 12:53:40 +00:00
|
|
|
// rootStore: popup.rootStore
|
|
|
|
// messageStore: popup.messageStore
|
2021-10-01 15:58:36 +00:00
|
|
|
/////////////TODO Remove
|
2021-12-09 12:53:40 +00:00
|
|
|
// fromAuthor: model.fromAuthor
|
|
|
|
// chatId: model.chatId
|
|
|
|
// userName: model.userName
|
|
|
|
// alias: model.alias
|
|
|
|
// localName: model.localName
|
|
|
|
// message: model.message
|
|
|
|
// plainText: model.plainText
|
|
|
|
// identicon: model.identicon
|
|
|
|
// isCurrentUser: model.isCurrentUser
|
|
|
|
// timestamp: model.timestamp
|
|
|
|
// sticker: model.sticker
|
|
|
|
// contentType: model.contentType
|
|
|
|
// outgoingStatus: model.outgoingStatus
|
|
|
|
// responseTo: model.responseTo
|
|
|
|
// imageClick: imagePopup.openPopup.bind(imagePopup)
|
|
|
|
// messageId: model.messageId
|
|
|
|
// emojiReactions: model.emojiReactions
|
|
|
|
// linkUrls: model.linkUrls
|
|
|
|
// communityId: model.communityId
|
|
|
|
// hasMention: model.hasMention
|
|
|
|
// stickerPackId: model.stickerPackId
|
|
|
|
// timeout: model.timeout
|
|
|
|
// pinnedMessage: true
|
|
|
|
// pinnedBy: model.pinnedBy
|
|
|
|
// forceHoverHandler: !messageToPin
|
|
|
|
// activityCenterMessage: false
|
|
|
|
// isEdited: model.isEdited
|
|
|
|
// showEdit: false
|
|
|
|
// messageContextMenu: msgContextMenu
|
|
|
|
// Component.onCompleted: {
|
|
|
|
// messageStore.fromAuthor = model.fromAuthor;
|
|
|
|
// messageStore.chatId = model.chatId;
|
|
|
|
// messageStore.userName = model.userName;
|
|
|
|
// messageStore.alias = model.alias;
|
|
|
|
// messageStore.localName = model.localName;
|
|
|
|
// messageStore.message = model.message;
|
|
|
|
// messageStore.plainText = model.plainText;
|
|
|
|
// messageStore.identicon = model.identicon;
|
|
|
|
// messageStore.isCurrentUser = model.isCurrentUser;
|
|
|
|
// messageStore.timestamp = model.timestamp;
|
|
|
|
// messageStore.sticker = model.sticker;
|
|
|
|
// messageStore.contentType = model.contentType;
|
|
|
|
// messageStore.outgoingStatus = model.outgoingStatus;
|
|
|
|
// messageStore.responseTo = model.responseTo;
|
|
|
|
// messageStore.imageClick = imagePopup.openPopup.bind(imagePopup);
|
|
|
|
// messageStore.messageId = model.messageId;
|
|
|
|
// messageStore.emojiReactions = model.emojiReactions;
|
|
|
|
// messageStore.linkUrls = model.linkUrls;
|
|
|
|
// messageStore.communityId = model.communityId;
|
|
|
|
// messageStore.hasMention = model.hasMention;
|
|
|
|
// messageStore.stickerPackId = model.stickerPackId;
|
|
|
|
// messageStore.timeout = model.timeout;
|
|
|
|
// messageStore.pinnedMessage = true;
|
|
|
|
// messageStore.pinnedBy = model.pinnedBy;
|
|
|
|
// messageStore.forceHoverHandler = !messageToPin;
|
|
|
|
// messageStore.activityCenterMessage = false;
|
|
|
|
// messageStore.isEdited = model.isEdited;
|
|
|
|
// messageStore.showEdit = false;
|
|
|
|
// messageStore.messageContextMenu = msgContextMenu;
|
|
|
|
// }
|
2021-07-26 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
enabled: !!messageToPin
|
|
|
|
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
|
|
|
|
visible: !!messageToPin
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 18
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
ButtonGroup.group: pinButtonGroup
|
|
|
|
function toggle() {
|
|
|
|
radio.checked = !radio.checked
|
|
|
|
if (radio.checked) {
|
|
|
|
messageToUnpin = model.messageId
|
|
|
|
}
|
2021-07-22 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-25 19:38:18 +00:00
|
|
|
}
|
2021-11-02 19:58:48 +00:00
|
|
|
}
|
|
|
|
MessageContextMenuView {
|
|
|
|
id: msgContextMenu
|
|
|
|
pinnedPopup: true
|
|
|
|
pinnedMessage: true
|
2021-12-14 14:19:55 +00:00
|
|
|
// chatSectionModule: popup.chatSectionModule
|
|
|
|
// store: popup.rootStore
|
|
|
|
// reactionModel: popup.rootStore.emojiReactionsModel
|
2021-11-02 19:58:48 +00:00
|
|
|
onShouldCloseParentPopup: {
|
|
|
|
popup.close()
|
|
|
|
}
|
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
|
|
|
|
visible: !!messageToPin
|
|
|
|
enabled: !!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-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// const chatId = popup.rootStore.chatsModelInst.channelView.activeChannel.id
|
|
|
|
// popup.rootStore.chatsModelInst.messageView.unPinMessage(messageToUnpin, chatId)
|
|
|
|
// popup.rootStore.chatsModelInst.messageView.pinMessage(messageToPin, chatId)
|
2021-07-26 17:27:09 +00:00
|
|
|
messageToUnpin = messageToPin = ""
|
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
|
|
|
}
|