2020-06-17 15:18:31 -04:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-28 07:06:17 -04:00
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../components"
|
2020-09-23 15:03:55 -04:00
|
|
|
import "./"
|
2020-05-28 07:06:17 -04:00
|
|
|
|
2021-02-02 15:03:21 -05:00
|
|
|
Item {
|
2020-12-11 15:29:46 -05:00
|
|
|
property var channelModel
|
2020-05-28 07:06:17 -04:00
|
|
|
property alias channelListCount: chatGroupsListView.count
|
2020-06-18 14:06:02 -04:00
|
|
|
property string searchStr: ""
|
2020-12-11 15:29:46 -05:00
|
|
|
id: channelListContent
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
2020-09-23 15:03:55 -04:00
|
|
|
|
2020-10-14 14:10:21 +02:00
|
|
|
Timer {
|
|
|
|
id: timer
|
|
|
|
}
|
|
|
|
|
2020-12-11 15:29:46 -05:00
|
|
|
ListView {
|
|
|
|
id: chatGroupsListView
|
2021-04-07 10:59:00 -04:00
|
|
|
spacing: 0
|
2020-09-23 15:03:55 -04:00
|
|
|
anchors.top: parent.top
|
2020-12-11 15:29:46 -05:00
|
|
|
height: childrenRect.height
|
2021-02-10 15:41:00 -05:00
|
|
|
visible: height > (appSettings.useCompactMode ? 30 : 50)
|
2020-09-23 15:03:55 -04:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
2020-12-11 15:29:46 -05: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) {
|
2021-02-11 13:13:21 -05:00
|
|
|
currentIndex = chatsModel.activeChannelIndex;
|
2020-12-11 15:29:46 -05:00
|
|
|
} else {
|
|
|
|
if (chatsModel.activeChannelIndex > -1) {
|
|
|
|
chatGroupsListView.currentIndex = 0;
|
2020-06-05 10:50:39 -04:00
|
|
|
} else {
|
2020-12-11 15:29:46 -05:00
|
|
|
// Initial state. No chat has been selected yet
|
|
|
|
chatGroupsListView.currentIndex = -1;
|
2020-06-05 10:50:39 -04:00
|
|
|
}
|
2020-05-29 14:24:48 -04:00
|
|
|
}
|
|
|
|
}
|
2020-12-11 15:29:46 -05:00
|
|
|
}
|
2020-05-29 14:24:48 -04:00
|
|
|
|
2021-03-26 13:57:30 -04:00
|
|
|
Item {
|
2020-12-11 15:29:46 -05:00
|
|
|
id: noSearchResults
|
|
|
|
anchors.top: parent.top
|
|
|
|
height: visible ? 300 : 0
|
|
|
|
visible: !chatGroupsListView.visible && channelListContent.searchStr !== ""
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-10-06 11:24:51 +02:00
|
|
|
|
2020-12-11 15:29:46 -05:00
|
|
|
StyledText {
|
|
|
|
font.pixelSize: 15
|
2021-03-16 15:19:48 -04:00
|
|
|
color: Style.current.secondaryText
|
2020-12-11 15:29:46 -05:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-02-18 11:36:05 -05:00
|
|
|
//% "No search results"
|
|
|
|
text: qsTrId("no-search-results")
|
2020-09-23 15:11:27 -04:00
|
|
|
}
|
|
|
|
}
|
2020-09-23 15:03:55 -04:00
|
|
|
|
2021-01-21 15:39:27 +01:00
|
|
|
ChannelContextMenu {
|
2020-08-03 15:05:49 -04:00
|
|
|
id: channelContextMenu
|
|
|
|
}
|
|
|
|
|
2020-05-29 14:24:48 -04:00
|
|
|
Connections {
|
|
|
|
target: chatsModel.chats
|
|
|
|
onDataChanged: {
|
|
|
|
// If the current active channel receives messages and changes its position,
|
|
|
|
// refresh the currentIndex accordingly
|
2020-06-02 16:10:48 -04:00
|
|
|
if(chatsModel.activeChannelIndex !== chatGroupsListView.currentIndex){
|
2020-05-29 14:24:48 -04:00
|
|
|
chatGroupsListView.currentIndex = chatsModel.activeChannelIndex
|
2020-05-28 10:58:25 -04:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 07:06:17 -04:00
|
|
|
}
|
2020-06-22 13:24:01 -04:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel
|
|
|
|
onActiveChannelChanged: {
|
2020-09-07 13:47:00 +02:00
|
|
|
chatsModel.hideLoadingIndicator()
|
2020-06-22 13:24:01 -04:00
|
|
|
chatGroupsListView.currentIndex = chatsModel.activeChannelIndex
|
2020-07-10 18:22:39 -04:00
|
|
|
SelectedMessage.reset();
|
|
|
|
chatColumn.isReply = false;
|
2020-06-22 13:24:01 -04:00
|
|
|
}
|
|
|
|
}
|
2020-06-17 15:18:31 -04:00
|
|
|
}
|
2020-12-11 15:29:46 -05:00
|
|
|
|
|
|
|
|
2020-06-17 15:18:31 -04:00
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|