2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-27 21:59:34 +00:00
|
|
|
import "../../../../shared"
|
2020-09-22 14:45:09 +00:00
|
|
|
import "../../../../shared/status"
|
2020-05-27 21:59:34 +00:00
|
|
|
import "../../../../imports"
|
2020-06-02 09:54:46 +00:00
|
|
|
import "../components"
|
2020-05-27 21:59:34 +00:00
|
|
|
|
2021-04-28 15:30:41 +00:00
|
|
|
Item {
|
2020-08-14 12:08:09 +00:00
|
|
|
property int iconSize: 16
|
2020-05-27 21:59:34 +00:00
|
|
|
id: chatTopBarContent
|
|
|
|
height: 56
|
|
|
|
|
2020-09-22 14:50:14 +00:00
|
|
|
Loader {
|
|
|
|
property bool isGroupChatOrOneToOne: (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat ||
|
|
|
|
chatsModel.activeChannel.chatType === Constants.chatTypeOneToOne)
|
2020-07-15 16:09:20 +00:00
|
|
|
anchors.left: parent.left
|
2020-09-22 14:50:14 +00:00
|
|
|
anchors.leftMargin: this.isGroupChatOrOneToOne ? Style.current.padding : Style.current.padding + 4
|
2020-07-15 16:09:20 +00:00
|
|
|
anchors.top: parent.top
|
2020-09-22 14:50:14 +00:00
|
|
|
anchors.topMargin: 4
|
|
|
|
sourceComponent: this.isGroupChatOrOneToOne ? chatInfoButton : chatInfo
|
2020-05-27 21:59:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-22 14:50:14 +00:00
|
|
|
Component {
|
|
|
|
id: chatInfoButton
|
|
|
|
StatusChatInfoButton {
|
2020-10-02 19:25:33 +00:00
|
|
|
chatId: chatsModel.activeChannel.id
|
2021-02-17 20:48:12 +00:00
|
|
|
chatName: {
|
|
|
|
if (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
|
|
|
|
return chatsModel.activeChannel.name
|
|
|
|
}
|
|
|
|
chatsModel.userNameOrAlias(chatsModel.activeChannel.id)
|
|
|
|
}
|
2020-09-22 14:50:14 +00:00
|
|
|
chatType: chatsModel.activeChannel.chatType
|
|
|
|
identicon: chatsModel.activeChannel.identicon
|
2021-01-15 18:36:42 +00:00
|
|
|
muted: chatsModel.activeChannel.muted
|
2020-09-22 14:50:14 +00:00
|
|
|
identiconSize: 36
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
switch (chatsModel.activeChannel.chatType) {
|
2021-02-17 20:36:10 +00:00
|
|
|
case Constants.chatTypePrivateGroupChat:
|
|
|
|
openPopup(groupInfoPopupComponent, {channel: chatsModel.activeChannel})
|
2020-09-22 14:50:14 +00:00
|
|
|
break;
|
|
|
|
case Constants.chatTypeOneToOne:
|
2020-12-21 12:08:44 +00:00
|
|
|
const profileImage = appMain.getProfileImage(chatsModel.activeChannel.id)
|
2021-02-11 15:43:49 +00:00
|
|
|
openProfilePopup(chatsModel.userNameOrAlias(chatsModel.activeChannel.id),
|
|
|
|
chatsModel.activeChannel.id, profileImage || chatsModel.activeChannel.identicon,
|
|
|
|
"", chatsModel.activeChannel.nickname)
|
2020-09-22 14:50:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-08-07 19:26:51 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 21:59:34 +00:00
|
|
|
}
|
|
|
|
|
2020-09-22 14:50:14 +00:00
|
|
|
Component {
|
|
|
|
id: chatInfo
|
|
|
|
StatusChatInfo {
|
|
|
|
identiconSize: 36
|
2021-03-02 20:43:32 +00:00
|
|
|
chatId: chatsModel.activeChannel.id
|
2020-09-22 14:50:14 +00:00
|
|
|
chatName: chatsModel.activeChannel.name
|
|
|
|
chatType: chatsModel.activeChannel.chatType
|
|
|
|
identicon: chatsModel.activeChannel.identicon
|
2021-01-15 18:36:42 +00:00
|
|
|
muted: chatsModel.activeChannel.muted
|
2020-06-09 15:48:17 +00:00
|
|
|
}
|
2020-05-27 21:59:34 +00:00
|
|
|
}
|
|
|
|
|
2021-03-17 09:22:35 +00:00
|
|
|
StatusContextMenuButton {
|
|
|
|
id: moreActionsBtn
|
2020-05-27 21:59:34 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
2020-07-09 17:56:31 +00:00
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
|
|
|
|
2021-03-17 09:22:35 +00:00
|
|
|
onClicked: {
|
|
|
|
var menu = chatContextMenu;
|
|
|
|
var isPrivateGroupChat = chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat
|
|
|
|
if(isPrivateGroupChat){
|
|
|
|
menu = groupContextMenu
|
2020-07-09 17:56:31 +00:00
|
|
|
}
|
2020-06-10 19:41:03 +00:00
|
|
|
|
2021-03-17 09:22:35 +00:00
|
|
|
if (menu.opened) {
|
|
|
|
return menu.close()
|
|
|
|
}
|
2021-01-11 20:08:35 +00:00
|
|
|
|
2021-03-17 09:22:35 +00:00
|
|
|
if (isPrivateGroupChat) {
|
|
|
|
menu.popup(moreActionsBtn.x, moreActionsBtn.height)
|
|
|
|
} else {
|
|
|
|
menu.openMenu(chatsModel.activeChannel, chatsModel.getActiveChannelIdx(),
|
|
|
|
moreActionsBtn.x - chatContextMenu.width + moreActionsBtn.width + 4,
|
|
|
|
moreActionsBtn.height - 4)
|
2020-05-27 21:59:34 +00:00
|
|
|
}
|
2021-03-17 09:22:35 +00:00
|
|
|
}
|
2020-05-27 21:59:34 +00:00
|
|
|
|
2021-03-17 09:22:35 +00:00
|
|
|
ChannelContextMenu {
|
|
|
|
id: chatContextMenu
|
2021-04-01 18:22:08 +00:00
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
2021-03-17 09:22:35 +00:00
|
|
|
}
|
2021-01-21 14:39:27 +00:00
|
|
|
|
2021-03-17 09:22:35 +00:00
|
|
|
PopupMenu {
|
|
|
|
id: groupContextMenu
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
|
|
|
Action {
|
|
|
|
icon.source: "../../../img/group_chat.svg"
|
|
|
|
icon.width: chatTopBarContent.iconSize
|
|
|
|
icon.height: chatTopBarContent.iconSize
|
|
|
|
//% "Group Information"
|
|
|
|
text: qsTrId("group-information")
|
|
|
|
onTriggered: openPopup(groupInfoPopupComponent, {channel: chatsModel.activeChannel})
|
2020-05-27 21:59:34 +00:00
|
|
|
}
|
2021-03-17 09:22:35 +00:00
|
|
|
Action {
|
|
|
|
icon.source: "../../../img/close.svg"
|
|
|
|
icon.width: chatTopBarContent.iconSize
|
|
|
|
icon.height: chatTopBarContent.iconSize
|
|
|
|
//% "Clear History"
|
|
|
|
text: qsTrId("clear-history")
|
|
|
|
onTriggered: chatsModel.clearChatHistory(chatsModel.activeChannel.id)
|
|
|
|
}
|
|
|
|
Action {
|
|
|
|
icon.source: "../../../img/leave_chat.svg"
|
|
|
|
icon.width: chatTopBarContent.iconSize
|
|
|
|
icon.height: chatTopBarContent.iconSize
|
|
|
|
//% "Leave group"
|
|
|
|
text: qsTrId("leave-group")
|
|
|
|
onTriggered: {
|
|
|
|
//% "Leave group"
|
|
|
|
deleteChatConfirmationDialog.title = qsTrId("leave-group")
|
|
|
|
//% "Leave group"
|
|
|
|
deleteChatConfirmationDialog.confirmButtonLabel = qsTrId("leave-group")
|
|
|
|
//% "Are you sure you want to leave this chat?"
|
|
|
|
deleteChatConfirmationDialog.confirmationText = qsTrId("are-you-sure-you-want-to-leave-this-chat-")
|
|
|
|
deleteChatConfirmationDialog.open()
|
2020-06-10 19:41:03 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 21:59:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-10 13:06:46 +00:00
|
|
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
id: deleteChatConfirmationDialog
|
2021-01-13 20:26:30 +00:00
|
|
|
btnType: "warn"
|
2020-08-10 13:06:46 +00:00
|
|
|
onConfirmButtonClicked: {
|
|
|
|
chatsModel.leaveActiveChat()
|
|
|
|
deleteChatConfirmationDialog.close()
|
|
|
|
}
|
|
|
|
}
|
2020-06-02 09:54:46 +00:00
|
|
|
}
|