2020-06-17 15:18:31 -04:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-27 17:59:34 -04:00
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../imports"
|
2020-06-02 11:54:46 +02:00
|
|
|
import "../components"
|
2020-05-27 17:59:34 -04:00
|
|
|
|
|
|
|
Rectangle {
|
2020-06-02 14:00:38 +02:00
|
|
|
property string channelNameStr: "#" + chatsModel.activeChannel.id
|
2020-08-14 08:08:09 -04:00
|
|
|
property int iconSize: 16
|
2020-05-27 17:59:34 -04:00
|
|
|
|
|
|
|
id: chatTopBarContent
|
2020-07-13 14:45:54 -04:00
|
|
|
color: Style.current.background
|
2020-05-27 17:59:34 -04:00
|
|
|
height: 56
|
|
|
|
Layout.fillWidth: true
|
2020-07-13 14:45:54 -04:00
|
|
|
border.color: Style.current.border
|
2020-05-27 17:59:34 -04:00
|
|
|
border.width: 1
|
|
|
|
|
2020-06-02 11:54:46 +02:00
|
|
|
ChannelIcon {
|
|
|
|
id: channelIcon
|
2020-06-09 17:20:42 -04:00
|
|
|
channelName: chatsModel.activeChannel.name
|
2020-06-02 14:00:38 +02:00
|
|
|
channelType: chatsModel.activeChannel.chatType
|
|
|
|
channelIdenticon: chatsModel.activeChannel.identicon
|
2020-07-15 12:09:20 -04:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2020-05-27 17:59:34 -04:00
|
|
|
}
|
|
|
|
|
2020-06-19 14:21:02 -04:00
|
|
|
StyledTextEdit {
|
2020-05-27 17:59:34 -04:00
|
|
|
id: channelName
|
|
|
|
width: 80
|
|
|
|
height: 20
|
2020-08-07 15:26:51 -04:00
|
|
|
text: {
|
|
|
|
switch(chatsModel.activeChannel.chatType) {
|
|
|
|
case Constants.chatTypePublic: return channelNameStr;
|
|
|
|
case Constants.chatTypeOneToOne: return Utils.removeStatusEns(chatsModel.activeChannel.name)
|
|
|
|
default: return chatsModel.activeChannel.name
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 17:59:34 -04:00
|
|
|
anchors.left: channelIcon.right
|
2020-07-02 11:14:31 -04:00
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
2020-05-27 17:59:34 -04:00
|
|
|
anchors.top: parent.top
|
2020-07-02 11:14:31 -04:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2020-05-27 17:59:34 -04:00
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 15
|
|
|
|
selectByMouse: true
|
|
|
|
readOnly: true
|
|
|
|
}
|
|
|
|
|
2020-06-19 14:06:58 -04:00
|
|
|
StyledText {
|
2020-05-27 17:59:34 -04:00
|
|
|
id: channelIdentifier
|
2020-07-02 11:14:31 -04:00
|
|
|
color: Style.current.darkGrey
|
2020-06-09 11:48:17 -04:00
|
|
|
text: {
|
|
|
|
switch(chatsModel.activeChannel.chatType){
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Public chat"
|
|
|
|
case Constants.chatTypePublic: return qsTrId("public-chat")
|
|
|
|
case Constants.chatTypeOneToOne: return (profileModel.isAdded(chatsModel.activeChannel.id) ?
|
|
|
|
//% "Contact"
|
|
|
|
qsTrId("chat-is-a-contact") :
|
|
|
|
//% "Not a contact"
|
|
|
|
qsTrId("chat-is-not-a-contact"))
|
2020-06-11 13:50:36 -04:00
|
|
|
case Constants.chatTypePrivateGroupChat:
|
2020-06-12 11:08:30 -04:00
|
|
|
let cnt = chatsModel.activeChannel.members.rowCount();
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "%1 members"
|
|
|
|
if(cnt > 1) return qsTrId("%1-members").arg(cnt);
|
|
|
|
//% "1 member"
|
|
|
|
return qsTrId("1-member");
|
2020-06-12 11:33:32 -04:00
|
|
|
default: return "...";
|
2020-06-09 11:48:17 -04:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 17:59:34 -04:00
|
|
|
font.pixelSize: 12
|
|
|
|
anchors.left: channelIcon.right
|
2020-07-02 11:14:31 -04:00
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
2020-05-27 17:59:34 -04:00
|
|
|
anchors.top: channelName.bottom
|
|
|
|
anchors.topMargin: 0
|
|
|
|
}
|
|
|
|
|
2020-07-09 13:56:31 -04:00
|
|
|
Rectangle {
|
|
|
|
id: moreActionsBtnContainer
|
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
radius: Style.current.radius
|
|
|
|
color: Style.current.transparent
|
2020-05-27 17:59:34 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
2020-07-09 13:56:31 -04:00
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: moreActionsBtn
|
|
|
|
text: "..."
|
|
|
|
font.letterSpacing: 0.5
|
|
|
|
font.bold: true
|
|
|
|
lineHeight: 1.4
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
font.pixelSize: 25
|
|
|
|
}
|
2020-05-27 17:59:34 -04:00
|
|
|
|
|
|
|
MouseArea {
|
2020-07-09 13:36:42 -04:00
|
|
|
property bool menuOpened: false
|
|
|
|
|
2020-05-27 17:59:34 -04:00
|
|
|
id: mouseArea
|
|
|
|
anchors.fill: parent
|
2020-07-09 13:56:31 -04:00
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: {
|
2020-07-13 14:45:54 -04:00
|
|
|
parent.color = Style.current.border
|
2020-07-09 13:56:31 -04:00
|
|
|
}
|
|
|
|
onExited: {
|
|
|
|
parent.color = Style.current.transparent
|
|
|
|
}
|
|
|
|
|
2020-05-27 17:59:34 -04:00
|
|
|
onClicked: {
|
2020-06-10 15:41:03 -04:00
|
|
|
var menu = chatContextMenu;
|
2020-07-09 13:56:31 -04:00
|
|
|
if(chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat){
|
2020-06-10 15:41:03 -04:00
|
|
|
menu = groupContextMenu
|
|
|
|
}
|
|
|
|
|
2020-07-09 13:36:42 -04:00
|
|
|
if (!menuOpened) {
|
|
|
|
menu.arrowX = menu.width - 40
|
2020-07-09 13:56:31 -04:00
|
|
|
menu.popup(moreActionsBtn.x, moreActionsBtn.height)
|
2020-07-09 13:36:42 -04:00
|
|
|
menuOpened = true
|
|
|
|
} else {
|
|
|
|
menu.dismiss()
|
|
|
|
menuOpened = false
|
|
|
|
}
|
2020-05-27 17:59:34 -04:00
|
|
|
}
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
|
|
|
PopupMenu {
|
2020-06-10 15:41:03 -04:00
|
|
|
id: chatContextMenu
|
2020-07-09 13:56:31 -04:00
|
|
|
onClosed: {
|
|
|
|
mouseArea.menuOpened = false
|
|
|
|
}
|
2020-06-18 11:47:30 +02:00
|
|
|
Action {
|
|
|
|
icon.source: "../../../img/close.svg"
|
2020-07-10 14:49:14 -04:00
|
|
|
icon.width: chatTopBarContent.iconSize
|
|
|
|
icon.height: chatTopBarContent.iconSize
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Clear history"
|
|
|
|
text: qsTrId("clear-history")
|
2020-06-18 11:47:30 +02:00
|
|
|
onTriggered: chatsModel.clearChatHistory(chatsModel.activeChannel.id)
|
|
|
|
}
|
2020-06-17 15:18:31 -04:00
|
|
|
Action {
|
2020-07-09 14:26:50 -04:00
|
|
|
icon.source: "../../../img/delete.svg"
|
2020-07-10 14:49:14 -04:00
|
|
|
icon.width: chatTopBarContent.iconSize
|
|
|
|
icon.height: chatTopBarContent.iconSize
|
2020-07-09 14:26:50 -04:00
|
|
|
icon.color: Style.current.red
|
2020-07-16 11:20:29 -04:00
|
|
|
//% "Delete Chat"
|
|
|
|
text: qsTrId("delete-chat")
|
2020-08-10 15:06:46 +02:00
|
|
|
onTriggered: {
|
|
|
|
//% "Delete Chat"
|
|
|
|
deleteChatConfirmationDialog.title = qsTrId("delete-chat")
|
|
|
|
//% "Delete Chat"
|
|
|
|
deleteChatConfirmationDialog.confirmButtonLabel = qsTrId("delete-chat")
|
|
|
|
deleteChatConfirmationDialog.confirmationText = qsTr("Are you sure you want to delete this chat?")
|
|
|
|
deleteChatConfirmationDialog.open()
|
|
|
|
}
|
2020-05-27 17:59:34 -04:00
|
|
|
}
|
|
|
|
}
|
2020-06-10 15:41:03 -04:00
|
|
|
|
|
|
|
PopupMenu {
|
|
|
|
id: groupContextMenu
|
2020-07-09 13:56:31 -04:00
|
|
|
onClosed: {
|
|
|
|
mouseArea.menuOpened = false
|
|
|
|
}
|
2020-06-17 15:18:31 -04:00
|
|
|
Action {
|
2020-06-11 13:50:36 -04:00
|
|
|
icon.source: "../../../img/group_chat.svg"
|
2020-07-10 14:49:14 -04:00
|
|
|
icon.width: chatTopBarContent.iconSize
|
|
|
|
icon.height: chatTopBarContent.iconSize
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Group Information"
|
|
|
|
text: qsTrId("group-information")
|
2020-06-11 13:50:36 -04:00
|
|
|
onTriggered: groupInfoPopup.open()
|
|
|
|
}
|
2020-06-18 11:47:30 +02:00
|
|
|
Action {
|
|
|
|
icon.source: "../../../img/close.svg"
|
2020-07-10 14:49:14 -04:00
|
|
|
icon.width: chatTopBarContent.iconSize
|
|
|
|
icon.height: chatTopBarContent.iconSize
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Clear history"
|
|
|
|
text: qsTrId("clear-history")
|
2020-06-18 11:47:30 +02:00
|
|
|
onTriggered: chatsModel.clearChatHistory(chatsModel.activeChannel.id)
|
|
|
|
}
|
2020-06-17 15:18:31 -04:00
|
|
|
Action {
|
2020-06-10 15:41:03 -04:00
|
|
|
icon.source: "../../../img/leave_chat.svg"
|
2020-07-10 14:49:14 -04:00
|
|
|
icon.width: chatTopBarContent.iconSize
|
|
|
|
icon.height: chatTopBarContent.iconSize
|
2020-07-06 16:39:55 -04:00
|
|
|
//% "Leave Group"
|
|
|
|
text: qsTrId("leave-group")
|
2020-08-10 15:06:46 +02:00
|
|
|
onTriggered: {
|
|
|
|
//% "Leave group"
|
|
|
|
deleteChatConfirmationDialog.title = qsTrId("leave-group")
|
|
|
|
//% "Leave group"
|
|
|
|
deleteChatConfirmationDialog.confirmButtonLabel = qsTrId("leave-group")
|
|
|
|
deleteChatConfirmationDialog.confirmationText = qsTr("Are you sure you want to leave this chat?")
|
|
|
|
deleteChatConfirmationDialog.open()
|
|
|
|
}
|
2020-06-10 15:41:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 13:50:36 -04:00
|
|
|
GroupInfoPopup {
|
|
|
|
id: groupInfoPopup
|
2020-08-06 15:37:09 +02:00
|
|
|
profileClick: {
|
|
|
|
profilePopup.openPopup.bind(profilePopup)
|
|
|
|
}
|
2020-07-09 13:56:31 -04:00
|
|
|
onClosed: {
|
|
|
|
mouseArea.menuOpened = false
|
|
|
|
}
|
2020-06-11 13:50:36 -04:00
|
|
|
}
|
2020-08-06 15:37:09 +02:00
|
|
|
|
|
|
|
ProfilePopup {
|
|
|
|
id: profilePopup
|
|
|
|
onClosed: {
|
|
|
|
if (!groupInfoPopup.opened) {
|
|
|
|
groupInfoPopup.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 17:59:34 -04:00
|
|
|
}
|
|
|
|
}
|
2020-08-10 15:06:46 +02:00
|
|
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
id: deleteChatConfirmationDialog
|
|
|
|
onConfirmButtonClicked: {
|
|
|
|
chatsModel.leaveActiveChat()
|
|
|
|
deleteChatConfirmationDialog.close()
|
|
|
|
}
|
|
|
|
}
|
2020-06-02 11:54:46 +02:00
|
|
|
}
|