2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-28 11:06:17 +00:00
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../components"
|
2020-09-23 19:03:55 +00:00
|
|
|
import "./"
|
2020-05-28 11:06:17 +00:00
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Rectangle {
|
|
|
|
property var channelModel
|
2020-05-28 11:06:17 +00:00
|
|
|
property alias channelListCount: chatGroupsListView.count
|
2020-06-18 18:06:02 +00:00
|
|
|
property string searchStr: ""
|
2020-12-11 20:29:46 +00:00
|
|
|
id: channelListContent
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
2021-01-05 16:36:42 +00:00
|
|
|
color: Style.current.transparent
|
2020-09-23 19:03:55 +00:00
|
|
|
|
2020-10-14 12:10:21 +00:00
|
|
|
Timer {
|
|
|
|
id: timer
|
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
ListView {
|
|
|
|
id: chatGroupsListView
|
|
|
|
spacing: Style.current.halfPadding
|
2020-09-23 19:03:55 +00:00
|
|
|
anchors.top: parent.top
|
2020-12-11 20:29:46 +00:00
|
|
|
height: childrenRect.height
|
2020-12-15 18:23:54 +00:00
|
|
|
visible: height > 50
|
2020-09-23 19:03:55 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
2020-12-11 20:29:46 +00:00
|
|
|
interactive: false
|
|
|
|
model: channelListContent.channelModel
|
|
|
|
delegate: Channel {
|
|
|
|
name: model.name
|
|
|
|
muted: model.muted
|
|
|
|
lastMessage: model.lastMessage
|
|
|
|
timestamp: model.timestamp
|
|
|
|
chatType: model.chatType
|
|
|
|
identicon: model.identicon
|
|
|
|
unviewedMessagesCount: model.unviewedMessagesCount
|
|
|
|
hasMentions: model.hasMentions
|
|
|
|
contentType: model.contentType
|
|
|
|
searchStr: channelListContent.searchStr
|
|
|
|
chatId: model.id
|
|
|
|
}
|
|
|
|
onCountChanged: {
|
|
|
|
if (count > 0 && chatsModel.activeChannelIndex > -1) {
|
|
|
|
// If a chat is added or removed, we set the current index to the first value
|
|
|
|
chatsModel.activeChannelIndex = 0;
|
|
|
|
currentIndex = 0;
|
|
|
|
} else {
|
|
|
|
if (chatsModel.activeChannelIndex > -1) {
|
|
|
|
chatGroupsListView.currentIndex = 0;
|
2020-06-05 14:50:39 +00:00
|
|
|
} else {
|
2020-12-11 20:29:46 +00:00
|
|
|
// Initial state. No chat has been selected yet
|
|
|
|
chatGroupsListView.currentIndex = -1;
|
2020-06-05 14:50:39 +00:00
|
|
|
}
|
2020-05-29 18:24:48 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
2020-05-29 18:24:48 +00:00
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Rectangle {
|
|
|
|
id: noSearchResults
|
|
|
|
anchors.top: parent.top
|
|
|
|
height: visible ? 300 : 0
|
|
|
|
color: "transparent"
|
|
|
|
visible: !chatGroupsListView.visible && channelListContent.searchStr !== ""
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-10-06 09:24:51 +00:00
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
StyledText {
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: qsTr("No search results")
|
2020-09-23 19:11:27 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-23 19:03:55 +00:00
|
|
|
|
2020-09-07 16:41:09 +00:00
|
|
|
GroupInfoPopup {
|
|
|
|
id: groupInfoPopup
|
|
|
|
onClosed: {
|
|
|
|
mouseArea.menuOpened = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-21 14:39:27 +00:00
|
|
|
ChannelContextMenu {
|
2020-08-03 19:05:49 +00:00
|
|
|
id: channelContextMenu
|
2021-01-21 14:39:27 +00:00
|
|
|
groupInfoPopup: groupInfoPopup
|
|
|
|
groupsListView: chatGroupsListView
|
2020-08-03 19:05:49 +00:00
|
|
|
}
|
|
|
|
|
2020-05-29 18:24:48 +00:00
|
|
|
Connections {
|
|
|
|
target: chatsModel.chats
|
|
|
|
onDataChanged: {
|
|
|
|
// If the current active channel receives messages and changes its position,
|
|
|
|
// refresh the currentIndex accordingly
|
2020-06-02 20:10:48 +00:00
|
|
|
if(chatsModel.activeChannelIndex !== chatGroupsListView.currentIndex){
|
2020-05-29 18:24:48 +00:00
|
|
|
chatGroupsListView.currentIndex = chatsModel.activeChannelIndex
|
2020-05-28 14:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 11:06:17 +00:00
|
|
|
}
|
2020-06-22 17:24:01 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel
|
|
|
|
onActiveChannelChanged: {
|
2020-09-07 11:47:00 +00:00
|
|
|
chatsModel.hideLoadingIndicator()
|
2020-06-22 17:24:01 +00:00
|
|
|
chatGroupsListView.currentIndex = chatsModel.activeChannelIndex
|
2020-07-10 22:22:39 +00:00
|
|
|
SelectedMessage.reset();
|
|
|
|
chatColumn.isReply = false;
|
2020-06-22 17:24:01 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
2020-06-17 19:18:31 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
|
|
|
2020-06-17 19:18:31 +00:00
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|