2021-07-06 09:42:51 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-15 10:59:01 +00:00
|
|
|
import Qt.labs.platform 1.1
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-07-06 09:42:51 +00:00
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.popups 1.0
|
2021-10-25 09:57:09 +00:00
|
|
|
import "../popups"
|
2021-12-23 21:06:27 +00:00
|
|
|
import "../popups/community"
|
2021-10-25 09:57:09 +00:00
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusPopupMenu {
|
2021-10-21 22:39:53 +00:00
|
|
|
id: root
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
property string currentFleet: ""
|
|
|
|
property bool isCommunityChat: false
|
|
|
|
property bool isCommunityAdmin: false
|
|
|
|
property string chatId: ""
|
|
|
|
property string chatName: ""
|
2021-12-21 09:26:13 +00:00
|
|
|
property string chatDescription: ""
|
2021-12-09 12:53:40 +00:00
|
|
|
property string chatIcon: ""
|
|
|
|
property int chatType: -1
|
|
|
|
property bool chatMuted: false
|
|
|
|
|
2021-12-21 09:26:13 +00:00
|
|
|
signal displayProfilePopup(string userId)
|
|
|
|
signal displayGroupInfoPopup(string chatId)
|
|
|
|
signal requestAllHistoricMessages(string chatId)
|
|
|
|
signal unmuteChat(string chatId)
|
|
|
|
signal muteChat(string chatId)
|
|
|
|
signal markAllMessagesRead(string chatId)
|
|
|
|
signal clearChatHistory(string chatId)
|
2021-12-09 12:53:40 +00:00
|
|
|
signal downloadMessages(string file)
|
2021-12-21 09:26:13 +00:00
|
|
|
signal deleteChat(string chatId)
|
|
|
|
signal leaveChat(string chatId)
|
|
|
|
|
|
|
|
signal openPinnedMessagesList(string chatId)
|
|
|
|
signal createCommunityChannel(string chatId, string newName, string newDescription)
|
|
|
|
signal editCommunityChannel(string chatId, string newName, string newDescription)
|
2021-07-06 09:42:51 +00:00
|
|
|
|
|
|
|
StatusMenuItem {
|
|
|
|
id: viewProfileMenuItem
|
|
|
|
text: {
|
2021-12-09 12:53:40 +00:00
|
|
|
switch (root.chatType) {
|
|
|
|
case Constants.chatType.oneToOne:
|
|
|
|
//% "View Profile"
|
|
|
|
return qsTrId("view-profile")
|
|
|
|
case Constants.chatType.privateGroupChat:
|
|
|
|
//% "View Group"
|
|
|
|
return qsTrId("view-group")
|
|
|
|
default:
|
|
|
|
return ""
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
icon.name: "group-chat"
|
2021-12-09 12:53:40 +00:00
|
|
|
enabled: root.chatType === Constants.chatType.oneToOne ||
|
|
|
|
root.chatType === Constants.chatType.privateGroupChat
|
2021-07-06 09:42:51 +00:00
|
|
|
onTriggered: {
|
2021-12-09 12:53:40 +00:00
|
|
|
if (root.chatType === Constants.chatType.oneToOne) {
|
2021-12-08 21:20:43 +00:00
|
|
|
const userProfileImage = Global.getProfileImage(root.chatId)
|
|
|
|
return Global.openProfilePopup(
|
|
|
|
root.chatName,
|
|
|
|
root.chatId,
|
|
|
|
root.chatIcon,
|
|
|
|
"",
|
|
|
|
root.chatName
|
|
|
|
)
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
|
|
|
if (root.chatType === Constants.chatType.privateGroupChat) {
|
|
|
|
root.displayGroupInfoPopup(root.chatId)
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuSeparator {
|
|
|
|
visible: viewProfileMenuItem.enabled
|
|
|
|
}
|
|
|
|
|
2021-07-20 17:23:43 +00:00
|
|
|
Action {
|
2021-12-21 09:26:13 +00:00
|
|
|
enabled: root.currentFleet == Constants.waku_prod ||
|
|
|
|
root.currentFleet === Constants.waku_test
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-07-22 15:03:59 +00:00
|
|
|
//% "Test WakuV2 - requestAllHistoricMessages"
|
|
|
|
text: qsTrId("test-wakuv2---requestallhistoricmessages")
|
2021-12-09 12:53:40 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.requestAllHistoricMessages(root.chatId)
|
|
|
|
}
|
2021-07-20 17:23:43 +00:00
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuItem {
|
2021-12-09 12:53:40 +00:00
|
|
|
text: root.chatMuted ?
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Unmute chat"
|
|
|
|
qsTrId("unmute-chat") :
|
|
|
|
//% "Mute chat"
|
|
|
|
qsTrId("mute-chat")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "notification"
|
2021-12-09 12:53:40 +00:00
|
|
|
enabled: root.chatType !== Constants.chatType.privateGroupChat
|
2021-07-06 09:42:51 +00:00
|
|
|
onTriggered: {
|
2021-12-09 12:53:40 +00:00
|
|
|
if(root.chatMuted)
|
|
|
|
root.unmuteChat(root.chatId)
|
|
|
|
else
|
|
|
|
root.muteChat(root.chatId)
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Mark as Read"
|
|
|
|
text: qsTrId("mark-as-read")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "checkmark-circle"
|
2021-12-09 12:53:40 +00:00
|
|
|
enabled: root.chatType !== Constants.chatType.privateGroupChat
|
|
|
|
onTriggered: {
|
2021-12-08 11:10:34 +00:00
|
|
|
root.markAllMessagesRead(root.chatId)
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Clear history"
|
|
|
|
text: qsTrId("clear-history")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "close-circle"
|
2021-12-09 12:53:40 +00:00
|
|
|
onTriggered: {
|
|
|
|
root.clearChatHistory(root.chatId)
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Edit Channel"
|
|
|
|
text: qsTrId("edit-channel")
|
2021-07-06 09:42:51 +00:00
|
|
|
icon.name: "edit"
|
2021-12-21 09:26:13 +00:00
|
|
|
enabled: root.isCommunityChat && root.isCommunityAdmin
|
|
|
|
onTriggered: {
|
2021-12-23 21:06:27 +00:00
|
|
|
Global.openPopup(editChannelPopup, {
|
|
|
|
isEdit: true,
|
|
|
|
channelName: root.chatName,
|
|
|
|
channelDescription: root.chatDescription
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: editChannelPopup
|
|
|
|
CreateChannelPopup {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
isEdit: true
|
|
|
|
onCreateCommunityChannel: {
|
|
|
|
root.createCommunityChannel(root.chatId, chName, chDescription);
|
|
|
|
}
|
|
|
|
onEditCommunityChannel: {
|
|
|
|
root.editCommunityChannel(root.chatId, chName, chDescription);
|
|
|
|
}
|
|
|
|
onOpenPinnedMessagesPopup: {
|
|
|
|
root.openPinnedMessagesList(root.chatId, chName, chDescription);
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2021-09-15 10:59:01 +00:00
|
|
|
StatusMenuItem {
|
|
|
|
text: qsTr("Download")
|
2021-10-20 09:50:50 +00:00
|
|
|
enabled: localAccountSensitiveSettings.downloadChannelMessagesEnabled
|
2021-09-15 10:59:01 +00:00
|
|
|
icon.name: "download"
|
|
|
|
onTriggered: downdloadDialog.open()
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
StatusMenuSeparator {
|
|
|
|
visible: deleteOrLeaveMenuItem.enabled
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
|
|
|
id: deleteOrLeaveMenuItem
|
2021-07-30 16:14:10 +00:00
|
|
|
text: {
|
2021-12-21 09:26:13 +00:00
|
|
|
if (root.isCommunityChat) {
|
2021-07-30 16:14:10 +00:00
|
|
|
return qsTr("Delete Channel")
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
return root.chatType === Constants.chatType.oneToOne ?
|
2021-07-30 16:14:10 +00:00
|
|
|
//% "Delete chat"
|
|
|
|
qsTrId("delete-chat") :
|
|
|
|
//% "Leave chat"
|
|
|
|
qsTrId("leave-chat")
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
icon.name: root.chatType === Constants.chatType.oneToOne || root.isCommunityChat ? "delete" : "arrow-right"
|
|
|
|
icon.width: root.chatType === Constants.chatType.oneToOne || root.isCommunityChat ? 18 : 14
|
|
|
|
iconRotation: root.chatType === Constants.chatType.oneToOne || root.isCommunityChat ? 0 : 180
|
2021-07-06 09:42:51 +00:00
|
|
|
|
|
|
|
type: StatusMenuItem.Type.Danger
|
|
|
|
onTriggered: {
|
2021-12-07 20:33:12 +00:00
|
|
|
Global.openPopup(deleteChatConfirmationDialogComponent)
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2021-12-21 09:26:13 +00:00
|
|
|
enabled: !root.isCommunityChat || root.isCommunityAdmin
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2021-09-15 10:59:01 +00:00
|
|
|
FileDialog {
|
|
|
|
id: downdloadDialog
|
|
|
|
acceptLabel: qsTr("Save")
|
|
|
|
fileMode: FileDialog.SaveFile
|
|
|
|
title: qsTr("Download messages")
|
|
|
|
currentFile: StandardPaths.writableLocation(StandardPaths.DocumentsLocation) + "/messages.json"
|
|
|
|
defaultSuffix: "json"
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-09-15 10:59:01 +00:00
|
|
|
onAccepted: {
|
2021-12-09 12:53:40 +00:00
|
|
|
root.downloadMessages(downdloadDialog.currentFile)
|
2021-09-15 10:59:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
Component {
|
|
|
|
id: deleteChatConfirmationDialogComponent
|
|
|
|
ConfirmationDialog {
|
|
|
|
btnType: "warn"
|
2021-12-21 09:26:13 +00:00
|
|
|
header.title: root.isCommunityChat ? qsTr("Delete #%1").arg(root.chatName) :
|
2021-12-09 12:53:40 +00:00
|
|
|
root.chatType === Constants.chatType.oneToOne ?
|
2021-09-14 09:58:20 +00:00
|
|
|
//% "Delete chat"
|
|
|
|
qsTrId("delete-chat") :
|
|
|
|
//% "Leave chat"
|
|
|
|
qsTrId("leave-chat")
|
2021-12-21 09:26:13 +00:00
|
|
|
confirmButtonLabel: root.isCommunityChat ? qsTr("Delete") : header.title
|
|
|
|
confirmationText: root.isCommunityChat ? qsTr("Are you sure you want to delete #%1 channel?").arg(root.chatName) :
|
2021-12-09 12:53:40 +00:00
|
|
|
root.chatType === Constants.chatType.oneToOne ?
|
2021-09-14 09:58:20 +00:00
|
|
|
qsTr("Are you sure you want to delete this chat?"):
|
2021-07-30 16:14:10 +00:00
|
|
|
qsTr("Are you sure you want to leave this chat?")
|
2021-12-21 09:26:13 +00:00
|
|
|
showCancelButton: root.isCommunityChat
|
2021-09-14 09:58:20 +00:00
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2021-09-14 09:58:20 +00:00
|
|
|
onCancelButtonClicked: {
|
|
|
|
close()
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
onConfirmButtonClicked: {
|
2021-12-21 09:26:13 +00:00
|
|
|
if(root.isCommunityChat || root.chatType === Constants.chatType.oneToOne)
|
|
|
|
root.deleteChat(root.chatId)
|
|
|
|
else
|
|
|
|
root.leaveChat(root.chatId)
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-12-21 09:26:13 +00:00
|
|
|
close()
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|