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"
|
|
|
|
import "../../../../imports"
|
2020-06-02 09:54:46 +00:00
|
|
|
import "../components"
|
2020-05-27 21:59:34 +00:00
|
|
|
|
|
|
|
Rectangle {
|
2020-06-02 12:00:38 +00:00
|
|
|
property string channelNameStr: "#" + chatsModel.activeChannel.id
|
2020-05-27 21:59:34 +00:00
|
|
|
|
|
|
|
id: chatTopBarContent
|
|
|
|
color: "white"
|
|
|
|
height: 56
|
|
|
|
Layout.fillWidth: true
|
2020-07-02 15:14:31 +00:00
|
|
|
border.color: Style.current.grey
|
2020-05-27 21:59:34 +00:00
|
|
|
border.width: 1
|
|
|
|
|
2020-06-02 09:54:46 +00:00
|
|
|
ChannelIcon {
|
|
|
|
id: channelIcon
|
2020-06-09 21:20:42 +00:00
|
|
|
channelName: chatsModel.activeChannel.name
|
2020-06-02 12:00:38 +00:00
|
|
|
channelType: chatsModel.activeChannel.chatType
|
|
|
|
channelIdenticon: chatsModel.activeChannel.identicon
|
2020-05-27 21:59:34 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 18:21:02 +00:00
|
|
|
StyledTextEdit {
|
2020-05-27 21:59:34 +00:00
|
|
|
id: channelName
|
|
|
|
width: 80
|
|
|
|
height: 20
|
2020-06-09 15:48:17 +00:00
|
|
|
text: chatsModel.activeChannel.chatType != Constants.chatTypePublic ? chatsModel.activeChannel.name : channelNameStr
|
2020-05-27 21:59:34 +00:00
|
|
|
anchors.left: channelIcon.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
2020-05-27 21:59:34 +00:00
|
|
|
anchors.top: parent.top
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2020-05-27 21:59:34 +00:00
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 15
|
|
|
|
selectByMouse: true
|
|
|
|
readOnly: true
|
|
|
|
}
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-05-27 21:59:34 +00:00
|
|
|
id: channelIdentifier
|
2020-07-02 15:14:31 +00:00
|
|
|
color: Style.current.darkGrey
|
2020-06-09 15:48:17 +00:00
|
|
|
text: {
|
|
|
|
switch(chatsModel.activeChannel.chatType){
|
|
|
|
case Constants.chatTypePublic: return qsTr("Public chat")
|
2020-06-23 12:40:21 +00:00
|
|
|
case Constants.chatTypeOneToOne: return (profileModel.isAdded(chatsModel.activeChannel.id) ? qsTr("Contact") : qsTr("Not a contact"))
|
2020-06-11 17:50:36 +00:00
|
|
|
case Constants.chatTypePrivateGroupChat:
|
2020-06-12 15:08:30 +00:00
|
|
|
let cnt = chatsModel.activeChannel.members.rowCount();
|
2020-06-11 17:50:36 +00:00
|
|
|
if(cnt > 1) return qsTr("%1 members").arg(cnt);
|
|
|
|
return qsTr("1 member");
|
2020-06-12 15:33:32 +00:00
|
|
|
default: return "...";
|
2020-06-09 15:48:17 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 21:59:34 +00:00
|
|
|
font.pixelSize: 12
|
|
|
|
anchors.left: channelIcon.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
2020-05-27 21:59:34 +00:00
|
|
|
anchors.top: channelName.bottom
|
|
|
|
anchors.topMargin: 0
|
|
|
|
}
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-05-27 21:59:34 +00:00
|
|
|
id: moreActionsBtn
|
|
|
|
text: "..."
|
|
|
|
font.letterSpacing: 0.5
|
|
|
|
font.bold: true
|
|
|
|
lineHeight: 1.4
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 20
|
|
|
|
font.pixelSize: 25
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
// The negative margins are for the mouse area to be a bit more wide around the button and have more space for the click
|
|
|
|
anchors.topMargin: -10
|
|
|
|
anchors.bottomMargin: -10
|
|
|
|
anchors.rightMargin: -15
|
|
|
|
anchors.leftMargin: -15
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
2020-06-10 19:41:03 +00:00
|
|
|
var menu = chatContextMenu;
|
|
|
|
if(chatsModel.activeChannel.chatType == Constants.chatTypePrivateGroupChat){
|
|
|
|
menu = groupContextMenu
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.arrowX = menu.width - 40
|
|
|
|
menu.popup(moreActionsBtn.x, moreActionsBtn.height + 10)
|
|
|
|
|
2020-05-27 21:59:34 +00:00
|
|
|
}
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
|
|
|
PopupMenu {
|
2020-06-10 19:41:03 +00:00
|
|
|
id: chatContextMenu
|
2020-06-18 09:47:30 +00:00
|
|
|
Action {
|
|
|
|
icon.source: "../../../img/close.svg"
|
|
|
|
text: qsTr("Clear history")
|
|
|
|
onTriggered: chatsModel.clearChatHistory(chatsModel.activeChannel.id)
|
|
|
|
}
|
2020-06-17 19:18:31 +00:00
|
|
|
Action {
|
2020-06-10 19:41:03 +00:00
|
|
|
icon.source: "../../../img/leave_chat.svg"
|
2020-05-27 21:59:34 +00:00
|
|
|
text: qsTr("Leave Chat")
|
|
|
|
onTriggered: chatsModel.leaveActiveChat()
|
|
|
|
}
|
|
|
|
}
|
2020-06-10 19:41:03 +00:00
|
|
|
|
|
|
|
PopupMenu {
|
|
|
|
id: groupContextMenu
|
2020-06-17 19:18:31 +00:00
|
|
|
Action {
|
2020-06-11 17:50:36 +00:00
|
|
|
icon.source: "../../../img/group_chat.svg"
|
|
|
|
text: qsTr("Group Information")
|
|
|
|
onTriggered: groupInfoPopup.open()
|
|
|
|
}
|
2020-06-18 09:47:30 +00:00
|
|
|
Action {
|
|
|
|
icon.source: "../../../img/close.svg"
|
|
|
|
text: qsTr("Clear history")
|
|
|
|
onTriggered: chatsModel.clearChatHistory(chatsModel.activeChannel.id)
|
|
|
|
}
|
2020-06-17 19:18:31 +00:00
|
|
|
Action {
|
2020-06-10 19:41:03 +00:00
|
|
|
icon.source: "../../../img/leave_chat.svg"
|
|
|
|
text: qsTr("Leave Group")
|
|
|
|
onTriggered: chatsModel.leaveActiveChat()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 17:50:36 +00:00
|
|
|
GroupInfoPopup {
|
|
|
|
id: groupInfoPopup
|
|
|
|
}
|
2020-05-27 21:59:34 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-02 09:54:46 +00:00
|
|
|
}
|