2020-05-25 20:34:26 +00:00
|
|
|
import QtQuick 2.3
|
|
|
|
import QtQuick.Controls 2.3
|
2020-05-27 20:42:24 +00:00
|
|
|
import QtQuick.Controls 2.12 as QQC2
|
2020-05-25 20:34:26 +00:00
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import Qt.labs.platform 1.1
|
2020-05-27 21:09:12 +00:00
|
|
|
import "../../../shared"
|
2020-05-25 20:34:26 +00:00
|
|
|
import "../../../imports"
|
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
StackLayout {
|
|
|
|
property int chatGroupsListViewCount: 0
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
currentIndex: chatGroupsListViewCount > 0 ? 0 : 1
|
2020-05-26 15:55:32 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: chatColumn
|
2020-05-26 15:55:32 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
RowLayout {
|
|
|
|
id: chatTopBar
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
2020-05-26 15:55:32 +00:00
|
|
|
Layout.fillWidth: true
|
2020-05-26 18:16:07 +00:00
|
|
|
z: 60
|
2020-05-26 15:55:32 +00:00
|
|
|
|
|
|
|
Rectangle {
|
2020-05-26 18:16:07 +00:00
|
|
|
property string channelNameStr: "#" + chatsModel.activeChannel
|
2020-05-26 15:55:32 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
id: chatTopBarContent
|
|
|
|
color: "white"
|
|
|
|
height: 56
|
2020-05-25 20:34:26 +00:00
|
|
|
Layout.fillWidth: true
|
2020-05-26 18:16:07 +00:00
|
|
|
border.color: Theme.grey
|
|
|
|
border.width: 1
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
// TODO this should be the Identicon if it's a private chat
|
|
|
|
Rectangle {
|
|
|
|
id: channelIcon
|
|
|
|
width: 36
|
|
|
|
height: 36
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Theme.padding
|
2020-05-25 20:34:26 +00:00
|
|
|
anchors.top: parent.top
|
2020-05-26 18:16:07 +00:00
|
|
|
anchors.topMargin: Theme.smallPadding
|
|
|
|
color: {
|
2020-05-27 19:38:03 +00:00
|
|
|
if (!chatsModel.activeChannel) {
|
|
|
|
return Theme.transparent
|
|
|
|
}
|
2020-05-26 18:16:07 +00:00
|
|
|
const color = chatsModel.getChannelColor(chatsModel.activeChannel)
|
|
|
|
if (!color) {
|
|
|
|
return Theme.transparent
|
|
|
|
}
|
|
|
|
return color
|
|
|
|
}
|
|
|
|
radius: 50
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: channelIconText
|
|
|
|
color: "white"
|
|
|
|
opacity: 0.7
|
|
|
|
text: chatTopBarContent.channelNameStr.substring(1, 2).toUpperCase()
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 18
|
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TextEdit {
|
2020-05-26 18:16:07 +00:00
|
|
|
id: channelName
|
|
|
|
width: 80
|
|
|
|
height: 20
|
|
|
|
text: chatTopBarContent.channelNameStr
|
|
|
|
anchors.left: channelIcon.right
|
|
|
|
anchors.leftMargin: Theme.smallPadding
|
2020-05-25 20:34:26 +00:00
|
|
|
anchors.top: parent.top
|
2020-05-26 18:16:07 +00:00
|
|
|
anchors.topMargin: Theme.smallPadding
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 15
|
2020-05-25 20:34:26 +00:00
|
|
|
selectByMouse: true
|
|
|
|
readOnly: true
|
|
|
|
}
|
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
Text {
|
|
|
|
id: channelIdentifier
|
2020-05-25 20:34:26 +00:00
|
|
|
color: Theme.darkGrey
|
2020-05-26 18:16:07 +00:00
|
|
|
// TODO change this in case of private message
|
|
|
|
text: "Public chat"
|
|
|
|
font.pixelSize: 12
|
|
|
|
anchors.left: channelIcon.right
|
|
|
|
anchors.leftMargin: Theme.smallPadding
|
|
|
|
anchors.top: channelName.bottom
|
|
|
|
anchors.topMargin: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
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
|
2020-05-27 20:42:24 +00:00
|
|
|
onClicked: {
|
|
|
|
contextMenu.arrowX = contextMenu.width - 40
|
|
|
|
contextMenu.popup(moreActionsBtn.x, moreActionsBtn.height + 10)
|
|
|
|
}
|
2020-05-26 18:16:07 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2020-05-26 20:37:38 +00:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
|
2020-05-27 20:42:24 +00:00
|
|
|
PopupMenu {
|
2020-05-26 20:37:38 +00:00
|
|
|
id: contextMenu
|
2020-05-27 20:42:24 +00:00
|
|
|
QQC2.Action {
|
|
|
|
text: qsTr("Leave Chat")
|
2020-05-27 18:40:58 +00:00
|
|
|
onTriggered: chatsModel.leaveActiveChat()
|
|
|
|
}
|
2020-05-26 20:37:38 +00:00
|
|
|
}
|
2020-05-26 18:16:07 +00:00
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
RowLayout {
|
|
|
|
id: chatContainer
|
2020-05-25 20:34:26 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2020-05-26 18:16:07 +00:00
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: chatLogViewDelegate
|
|
|
|
Rectangle {
|
|
|
|
id: chatBox
|
|
|
|
height: 60 + chatText.height
|
|
|
|
color: "#00000000"
|
|
|
|
border.color: "#00000000"
|
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
|
|
|
Layout.fillWidth: true
|
|
|
|
width: chatLogView.width
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: chatImage
|
|
|
|
width: 30
|
|
|
|
height: 30
|
|
|
|
anchors.left: !isCurrentUser ? parent.left : undefined
|
|
|
|
anchors.leftMargin: !isCurrentUser ? Theme.padding : 0
|
|
|
|
anchors.right: !isCurrentUser ? undefined : parent.right
|
|
|
|
anchors.rightMargin: !isCurrentUser ? 0 : Theme.padding
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Theme.padding
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: identicon
|
|
|
|
}
|
|
|
|
|
|
|
|
TextEdit {
|
|
|
|
id: chatName
|
|
|
|
text: userName
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 22
|
|
|
|
anchors.left: !isCurrentUser ? chatImage.right : undefined
|
|
|
|
anchors.leftMargin: Theme.padding
|
|
|
|
anchors.right: !isCurrentUser ? undefined : chatImage.left
|
|
|
|
anchors.rightMargin: !isCurrentUser ? 0 : Theme.padding
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 14
|
|
|
|
readOnly: true
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
selectByMouse: true
|
|
|
|
}
|
|
|
|
|
|
|
|
TextEdit {
|
|
|
|
id: chatText
|
|
|
|
text: message
|
|
|
|
horizontalAlignment: !isCurrentUser ? Text.AlignLeft : Text.AlignRight
|
|
|
|
font.family: "Inter"
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
anchors.right: !isCurrentUser ? parent.right : chatName.right
|
|
|
|
anchors.rightMargin: !isCurrentUser ? 60 : 0
|
|
|
|
anchors.left: !isCurrentUser ? chatName.left : parent.left
|
|
|
|
anchors.leftMargin: !isCurrentUser ? 0 : 60
|
|
|
|
anchors.top: chatName.bottom
|
|
|
|
anchors.topMargin: Theme.padding
|
|
|
|
font.pixelSize: 14
|
|
|
|
readOnly: true
|
|
|
|
selectByMouse: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
TextEdit {
|
|
|
|
id: chatTime
|
|
|
|
color: Theme.darkGrey
|
|
|
|
font.family: "Inter"
|
|
|
|
text: timestamp
|
|
|
|
anchors.top: chatText.bottom
|
|
|
|
anchors.bottomMargin: Theme.padding
|
|
|
|
anchors.right: !isCurrentUser ? parent.right : undefined
|
|
|
|
anchors.rightMargin: !isCurrentUser ? Theme.padding : 0
|
|
|
|
anchors.left: !isCurrentUser ? undefined : parent.left
|
|
|
|
anchors.leftMargin: !isCurrentUser ? 0 : Theme.padding
|
|
|
|
font.pixelSize: 10
|
|
|
|
readOnly: true
|
|
|
|
selectByMouse: true
|
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
2020-05-26 18:16:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: chatLogView
|
|
|
|
model: chatsModel.messageList
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
delegate: chatLogViewDelegate
|
|
|
|
highlightFollowsCurrentItem: true
|
|
|
|
onCountChanged: {
|
|
|
|
if (!this.atYEnd) {
|
|
|
|
// User has scrolled up, we don't want to scroll back
|
2020-05-27 18:40:58 +00:00
|
|
|
return
|
2020-05-26 18:16:07 +00:00
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
// positionViewAtEnd doesn't work well. Instead, we use highlightFollowsCurrentItem
|
|
|
|
// and set the current Item/Index to the latest item
|
|
|
|
while (this.currentIndex < this.count - 1) {
|
|
|
|
this.incrementCurrentIndex()
|
|
|
|
}
|
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
RowLayout {
|
|
|
|
id: chatInputContainer
|
2020-05-25 20:34:26 +00:00
|
|
|
height: 70
|
|
|
|
Layout.fillWidth: true
|
2020-05-26 18:16:07 +00:00
|
|
|
Layout.bottomMargin: 0
|
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
|
|
|
|
transformOrigin: Item.Bottom
|
2020-05-25 20:34:26 +00:00
|
|
|
|
|
|
|
Rectangle {
|
2020-05-26 18:16:07 +00:00
|
|
|
id: element2
|
|
|
|
width: 200
|
|
|
|
height: 70
|
|
|
|
Layout.fillWidth: true
|
|
|
|
color: "white"
|
|
|
|
border.width: 0
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
Rectangle {
|
|
|
|
id: rectangle
|
|
|
|
color: "#00000000"
|
|
|
|
border.color: Theme.grey
|
|
|
|
anchors.fill: parent
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
Button {
|
|
|
|
id: chatSendBtn
|
|
|
|
x: 100
|
|
|
|
width: 30
|
|
|
|
height: 30
|
|
|
|
text: "\u2191"
|
|
|
|
font.bold: true
|
|
|
|
font.pointSize: 12
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 20
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 16
|
|
|
|
onClicked: {
|
|
|
|
chatsModel.onSend(txtData.text)
|
|
|
|
txtData.text = ""
|
|
|
|
}
|
|
|
|
enabled: txtData.text !== ""
|
|
|
|
background: Rectangle {
|
|
|
|
color: parent.enabled ? Theme.blue : Theme.grey
|
|
|
|
radius: 50
|
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
2020-05-26 18:16:07 +00:00
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: txtData
|
|
|
|
text: ""
|
|
|
|
leftPadding: 0
|
|
|
|
padding: 0
|
|
|
|
font.pixelSize: 14
|
|
|
|
placeholderText: qsTr("Type a message...")
|
|
|
|
anchors.right: chatSendBtn.left
|
|
|
|
anchors.rightMargin: 16
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 24
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
Keys.onEnterPressed: {
|
|
|
|
chatsModel.onSend(txtData.text)
|
|
|
|
txtData.text = ""
|
|
|
|
}
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
chatsModel.onSend(txtData.text)
|
|
|
|
txtData.text = ""
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
|
|
|
color: "#00000000"
|
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
MouseArea {
|
|
|
|
id: mouseArea1
|
|
|
|
anchors.rightMargin: 50
|
|
|
|
anchors.fill: parent
|
2020-05-27 18:40:58 +00:00
|
|
|
onClicked: {
|
2020-05-26 18:16:07 +00:00
|
|
|
txtData.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-26 18:16:07 +00:00
|
|
|
}
|
|
|
|
|
2020-05-27 17:56:25 +00:00
|
|
|
Item {
|
2020-05-27 18:40:58 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Item {
|
|
|
|
id: walkieTalkieContainer
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 200
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 200
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 200
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 100
|
|
|
|
Image {
|
|
|
|
source: "../../../onboarding/img/chat@2x.jpg"
|
|
|
|
}
|
2020-05-26 18:16:07 +00:00
|
|
|
|
2020-05-27 18:40:58 +00:00
|
|
|
Text {
|
|
|
|
text: "Select a chat to start messaging"
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
font.weight: Font.DemiBold
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.darkGrey
|
|
|
|
}
|
2020-05-26 18:16:07 +00:00
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-05-27 17:26:21 +00:00
|
|
|
D{i:0;formeditorColor:"#ffffff";height:770;width:800}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
|
|
|
##^##*/
|