2022-08-09 15:08:39 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2022-09-12 16:35:20 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2022-08-09 15:08:39 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
2023-06-23 06:17:04 +00:00
|
|
|
import shared.views.chat 1.0
|
|
|
|
|
2022-08-09 15:08:39 +00:00
|
|
|
import "../panels"
|
2022-09-30 14:36:49 +00:00
|
|
|
import "../stores"
|
2022-08-09 15:08:39 +00:00
|
|
|
|
2022-10-06 09:58:58 +00:00
|
|
|
Item {
|
2022-08-09 15:08:39 +00:00
|
|
|
id: root
|
|
|
|
|
|
|
|
property alias menuButton: menuButton
|
|
|
|
property alias membersButton: membersButton
|
|
|
|
property alias searchButton: searchButton
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property RootStore rootStore
|
2022-12-13 10:45:26 +00:00
|
|
|
property var chatContentModule: root.rootStore.currentChatContentModule() || null
|
2022-09-14 10:38:25 +00:00
|
|
|
property var emojiPopup
|
2022-09-20 10:54:28 +00:00
|
|
|
property int padding: Style.current.halfPadding
|
2022-08-09 15:08:39 +00:00
|
|
|
|
|
|
|
signal searchButtonClicked()
|
2024-02-06 09:31:36 +00:00
|
|
|
signal displayEditChannelPopup(string chatId,
|
|
|
|
string chatName,
|
|
|
|
string chatDescription,
|
|
|
|
string chatEmoji,
|
|
|
|
string chatColor,
|
|
|
|
string chatCategoryId,
|
|
|
|
int channelPosition,
|
2024-03-18 17:33:07 +00:00
|
|
|
var deleteDialog,
|
|
|
|
bool hideIfPermissionsNotMet)
|
2022-08-09 15:08:39 +00:00
|
|
|
|
2023-01-17 17:13:03 +00:00
|
|
|
function addRemoveGroupMember() {
|
|
|
|
root.state = d.stateMembersSelectorContent
|
|
|
|
}
|
|
|
|
|
2022-09-06 13:19:50 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property string stateInfoButtonContent: ""
|
|
|
|
readonly property string stateMembersSelectorContent: "selectingMembers"
|
|
|
|
|
|
|
|
readonly property bool selectingMembers: root.state == stateMembersSelectorContent
|
|
|
|
}
|
|
|
|
|
2022-09-30 14:36:49 +00:00
|
|
|
MessageStore {
|
|
|
|
id: messageStore
|
|
|
|
messageModule: chatContentModule ? chatContentModule.messagesModule : null
|
|
|
|
chatSectionModule: root.rootStore.chatCommunitySectionModule
|
|
|
|
}
|
|
|
|
|
2022-08-09 15:08:39 +00:00
|
|
|
Loader {
|
|
|
|
id: loader
|
2022-10-06 09:58:58 +00:00
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
2023-02-21 10:58:48 +00:00
|
|
|
anchors.right: d.selectingMembers ? parent.right : actionButtons.left
|
2022-10-06 09:58:58 +00:00
|
|
|
|
|
|
|
sourceComponent: d.selectingMembers ? membersSelector : statusChatInfoButton
|
|
|
|
}
|
|
|
|
|
2022-08-09 15:08:39 +00:00
|
|
|
RowLayout {
|
|
|
|
id: actionButtons
|
2022-10-06 09:58:58 +00:00
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
2022-08-09 15:08:39 +00:00
|
|
|
spacing: 8
|
2022-09-06 13:19:50 +00:00
|
|
|
visible: !d.selectingMembers
|
2022-08-09 15:08:39 +00:00
|
|
|
|
|
|
|
StatusFlatRoundButton {
|
|
|
|
id: searchButton
|
|
|
|
icon.name: "search"
|
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
onClicked: root.searchButtonClicked()
|
|
|
|
|
|
|
|
// initializing the tooltip
|
|
|
|
tooltip.text: qsTr("Search")
|
|
|
|
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
|
|
|
tooltip.y: parent.height + 12
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusFlatRoundButton {
|
|
|
|
id: membersButton
|
|
|
|
visible: {
|
2023-01-20 19:01:32 +00:00
|
|
|
if(!chatContentModule)
|
2022-08-09 15:08:39 +00:00
|
|
|
return false
|
|
|
|
|
|
|
|
return localAccountSensitiveSettings.showOnlineUsers &&
|
|
|
|
chatContentModule.chatDetails.isUsersListAvailable
|
|
|
|
}
|
|
|
|
highlighted: localAccountSensitiveSettings.expandUsersList
|
|
|
|
icon.name: "group-chat"
|
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
onClicked: {
|
|
|
|
localAccountSensitiveSettings.expandUsersList = !localAccountSensitiveSettings.expandUsersList;
|
|
|
|
}
|
|
|
|
// initializing the tooltip
|
|
|
|
tooltip.text: qsTr("Members")
|
|
|
|
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
|
|
|
tooltip.y: parent.height + 12
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusFlatRoundButton {
|
|
|
|
id: menuButton
|
|
|
|
objectName: "chatToolbarMoreOptionsButton"
|
|
|
|
icon.name: "more"
|
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
|
|
|
|
// initializing the tooltip
|
|
|
|
tooltip.visible: !!tooltip.text && menuButton.hovered && !contextMenu.opened
|
|
|
|
tooltip.text: qsTr("More")
|
|
|
|
tooltip.orientation: StatusToolTip.Orientation.Bottom
|
|
|
|
tooltip.y: parent.height + 12
|
|
|
|
|
|
|
|
property bool showMoreMenu: false
|
|
|
|
onClicked: {
|
|
|
|
menuButton.highlighted = true
|
|
|
|
|
|
|
|
let originalOpenHandler = contextMenu.openHandler
|
|
|
|
let originalCloseHandler = contextMenu.closeHandler
|
|
|
|
|
|
|
|
contextMenu.openHandler = function () {
|
|
|
|
if (!!originalOpenHandler) {
|
|
|
|
originalOpenHandler()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contextMenu.closeHandler = function () {
|
|
|
|
menuButton.highlighted = false
|
|
|
|
if (!!originalCloseHandler) {
|
|
|
|
originalCloseHandler()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contextMenu.openHandler = originalOpenHandler
|
|
|
|
contextMenu.popup(-contextMenu.width + menuButton.width, menuButton.height + 4)
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatContextMenuView {
|
|
|
|
id: contextMenu
|
|
|
|
objectName: "moreOptionsContextMenu"
|
2024-02-07 12:38:46 +00:00
|
|
|
showDebugOptions: root.rootStore.isDebugEnabled
|
2022-08-09 15:08:39 +00:00
|
|
|
openHandler: function () {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on open chat context menu handler - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
currentFleet = chatContentModule.getCurrentFleet()
|
|
|
|
isCommunityChat = chatContentModule.chatDetails.belongsToCommunity
|
|
|
|
amIChatAdmin = chatContentModule.amIChatAdmin()
|
|
|
|
chatId = chatContentModule.chatDetails.id
|
|
|
|
chatName = chatContentModule.chatDetails.name
|
|
|
|
chatDescription = chatContentModule.chatDetails.description
|
|
|
|
chatEmoji = chatContentModule.chatDetails.emoji
|
|
|
|
chatColor = chatContentModule.chatDetails.color
|
2022-09-07 10:03:51 +00:00
|
|
|
chatIcon = chatContentModule.chatDetails.icon
|
2022-08-09 15:08:39 +00:00
|
|
|
chatType = chatContentModule.chatDetails.type
|
|
|
|
chatMuted = chatContentModule.chatDetails.muted
|
|
|
|
channelPosition = chatContentModule.chatDetails.position
|
2024-03-18 17:33:07 +00:00
|
|
|
hideIfPermissionsNotMet = chatContentModule.chatDetails.hideIfPermissionsNotMet
|
2022-08-09 15:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onMuteChat: {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on mute chat from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
2023-05-26 12:54:10 +00:00
|
|
|
chatContentModule.muteChat(interval)
|
2022-08-09 15:08:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onUnmuteChat: {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on unmute chat from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chatContentModule.unmuteChat()
|
|
|
|
}
|
|
|
|
|
|
|
|
onMarkAllMessagesRead: {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on mark all messages read from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chatContentModule.markAllMessagesRead()
|
|
|
|
}
|
|
|
|
|
|
|
|
onClearChatHistory: {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on clear chat history from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chatContentModule.clearChatHistory()
|
|
|
|
}
|
|
|
|
|
|
|
|
onRequestAllHistoricMessages: {
|
|
|
|
// Not Refactored Yet - Check in the `master` branch if this is applicable here.
|
|
|
|
}
|
|
|
|
|
|
|
|
onLeaveChat: {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on leave chat from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chatContentModule.leaveChat()
|
|
|
|
}
|
|
|
|
|
|
|
|
onDeleteCommunityChat: root.rootStore.removeCommunityChat(chatId)
|
|
|
|
|
|
|
|
onDownloadMessages: {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on leave chat from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chatContentModule.downloadMessages(file)
|
|
|
|
}
|
|
|
|
|
|
|
|
onDisplayProfilePopup: {
|
|
|
|
Global.openProfilePopup(publicKey)
|
|
|
|
}
|
2024-02-06 09:31:36 +00:00
|
|
|
onDisplayEditChannelPopup: {
|
|
|
|
root.displayEditChannelPopup(chatId, chatName, chatDescription,
|
|
|
|
chatEmoji, chatColor,
|
|
|
|
chatCategoryId, channelPosition,
|
2024-03-18 17:33:07 +00:00
|
|
|
contextMenu.deleteChatConfirmationDialog,
|
|
|
|
hideIfPermissionsNotMet);
|
2022-08-09 15:08:39 +00:00
|
|
|
}
|
|
|
|
onAddRemoveGroupMember: {
|
2023-01-17 17:13:03 +00:00
|
|
|
root.addRemoveGroupMember()
|
2022-08-09 15:08:39 +00:00
|
|
|
}
|
2023-11-29 09:55:03 +00:00
|
|
|
onRequestMoreMessages: {
|
2022-09-30 14:36:49 +00:00
|
|
|
messageStore.requestMoreMessages();
|
2022-08-09 15:08:39 +00:00
|
|
|
}
|
|
|
|
onUpdateGroupChatDetails: {
|
|
|
|
root.rootStore.chatCommunitySectionModule.updateGroupChatDetails(
|
|
|
|
chatId,
|
|
|
|
groupName,
|
|
|
|
groupColor,
|
|
|
|
groupImage
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
implicitWidth: 1
|
|
|
|
implicitHeight: 24
|
|
|
|
color: Theme.palette.directColor7
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
visible: (menuButton.visible || membersButton.visible || searchButton.visible)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Chat toolbar content option 1:
|
|
|
|
Component {
|
|
|
|
id: statusChatInfoButton
|
|
|
|
|
|
|
|
StatusChatInfoButton {
|
2022-10-24 18:53:42 +00:00
|
|
|
readonly property string emojiIcon: chatContentModule? chatContentModule.chatDetails.emoji : "" // Needed for test
|
2024-01-26 15:54:30 +00:00
|
|
|
readonly property string assetName: chatContentModule && Utils.addTimestampToURL(chatContentModule.chatDetails.icon)
|
2022-10-24 18:53:42 +00:00
|
|
|
|
2022-08-09 15:08:39 +00:00
|
|
|
objectName: "chatInfoBtnInHeader"
|
2022-11-17 09:55:49 +00:00
|
|
|
title: chatContentModule? chatContentModule.chatDetails.name : ""
|
2022-09-22 22:18:15 +00:00
|
|
|
|
2022-08-09 15:08:39 +00:00
|
|
|
subTitle: {
|
|
|
|
if(!chatContentModule)
|
|
|
|
return ""
|
|
|
|
|
|
|
|
// In some moment in future this should be part of the backend logic.
|
2023-01-20 19:01:32 +00:00
|
|
|
// (once we add translation on the backend side)
|
2022-08-09 15:08:39 +00:00
|
|
|
switch (chatContentModule.chatDetails.type) {
|
|
|
|
case Constants.chatType.privateGroupChat:
|
2022-09-07 10:03:51 +00:00
|
|
|
return qsTr("%n member(s)", "", chatContentModule.usersModule.model.count)
|
2022-08-09 15:08:39 +00:00
|
|
|
case Constants.chatType.communityChat:
|
2022-09-12 16:35:20 +00:00
|
|
|
return SQUtils.Utils.linkifyAndXSS(chatContentModule.chatDetails.description).trim()
|
2022-08-09 15:08:39 +00:00
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2024-01-26 15:54:30 +00:00
|
|
|
asset.name: assetName
|
2022-12-13 10:45:26 +00:00
|
|
|
asset.isImage: chatContentModule && chatContentModule.chatDetails.icon !== ""
|
|
|
|
asset.isLetterIdenticon: chatContentModule && chatContentModule.chatDetails.icon === ""
|
2022-08-09 15:08:39 +00:00
|
|
|
ringSettings.ringSpecModel: chatContentModule && chatContentModule.chatDetails.type === Constants.chatType.oneToOne ?
|
|
|
|
Utils.getColorHashAsJson(chatContentModule.chatDetails.id) : ""
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.color: chatContentModule?
|
2022-08-09 15:08:39 +00:00
|
|
|
chatContentModule.chatDetails.type === Constants.chatType.oneToOne ?
|
|
|
|
Utils.colorForPubkey(chatContentModule.chatDetails.id)
|
|
|
|
: chatContentModule.chatDetails.color
|
|
|
|
: ""
|
2022-10-24 18:53:42 +00:00
|
|
|
asset.emoji: emojiIcon
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.emojiSize: "24x24"
|
2023-03-27 16:55:26 +00:00
|
|
|
type: chatContentModule ? chatContentModule.chatDetails.type : Constants.chatType.unknown
|
2022-08-09 15:08:39 +00:00
|
|
|
pinnedMessagesCount: chatContentModule? chatContentModule.pinnedMessagesModel.count : 0
|
|
|
|
muted: chatContentModule? chatContentModule.chatDetails.muted : false
|
|
|
|
|
|
|
|
onPinnedMessagesCountClicked: {
|
|
|
|
if(!chatContentModule) {
|
2022-09-19 08:40:02 +00:00
|
|
|
console.warn("error on open pinned messages - chat content module is not set")
|
2022-08-09 15:08:39 +00:00
|
|
|
return
|
|
|
|
}
|
2023-03-27 16:55:26 +00:00
|
|
|
const chatId = type === Constants.chatType.oneToOne ? chatContentModule.getMyChatId() : ""
|
|
|
|
Global.openPinnedMessagesPopupRequested(rootStore, messageStore, chatContentModule.pinnedMessagesModel, "", chatId)
|
2022-08-09 15:08:39 +00:00
|
|
|
}
|
|
|
|
onUnmute: {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on unmute chat - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chatContentModule.unmuteChat()
|
|
|
|
}
|
|
|
|
|
2022-09-14 10:41:29 +00:00
|
|
|
hoverEnabled: {
|
2022-08-09 15:08:39 +00:00
|
|
|
if(!chatContentModule)
|
|
|
|
return false
|
|
|
|
|
2023-01-20 19:01:32 +00:00
|
|
|
return chatContentModule.chatDetails.type !== Constants.chatType.communityChat &&
|
2022-09-08 07:49:24 +00:00
|
|
|
chatContentModule.chatDetails.type !== Constants.chatType.privateGroupChat
|
2022-08-09 15:08:39 +00:00
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
switch (chatContentModule.chatDetails.type) {
|
|
|
|
case Constants.chatType.oneToOne:
|
|
|
|
Global.openProfilePopup(chatContentModule.chatDetails.id)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-01-04 00:23:29 +00:00
|
|
|
onLinkActivated: Global.openLink(link)
|
2022-08-09 15:08:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Chat toolbar content option 2:
|
|
|
|
Component {
|
2022-09-06 13:19:50 +00:00
|
|
|
id: membersSelector
|
|
|
|
|
|
|
|
MembersEditSelectorView {
|
2022-08-09 15:08:39 +00:00
|
|
|
rootStore: root.rootStore
|
2022-11-08 08:36:08 +00:00
|
|
|
usersStore: UsersStore {
|
|
|
|
usersModule: root.chatContentModule.usersModule
|
|
|
|
}
|
2022-09-06 13:19:50 +00:00
|
|
|
|
|
|
|
onConfirmed: root.state = d.stateInfoButtonContent
|
|
|
|
onRejected: root.state = d.stateInfoButtonContent
|
2022-08-09 15:08:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|