status-desktop/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml

159 lines
5.0 KiB
QML
Raw Normal View History

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-07-22 16:24:07 +00:00
ScrollView {
2020-05-28 11:06:17 +00:00
property alias channelListCount: chatGroupsListView.count
property string searchStr: ""
2020-05-28 11:06:17 +00:00
id: chatGroupsContainer
Layout.fillHeight: true
Layout.fillWidth: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
2020-05-28 11:06:17 +00:00
ListView {
id: chatGroupsListView
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: parent.left
anchors.rightMargin: Style.current.padding
anchors.leftMargin: Style.current.padding
2020-07-22 16:24:07 +00:00
clip: true
2020-05-28 11:06:17 +00:00
model: chatsModel.chats
delegate: Channel {
name: model.name
lastMessage: model.lastMessage
timestamp: model.timestamp
chatType: model.chatType
unviewedMessagesCount: model.unviewedMessagesCount
hasMentions: model.hasMentions
contentType: model.contentType
searchStr: chatGroupsContainer.searchStr
}
2020-05-28 14:58:25 +00:00
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;
} else {
// Initial state. No chat has been selected yet
chatGroupsListView.currentIndex = -1;
}
}
}
}
2020-08-03 19:05:49 +00:00
PopupMenu {
property int channelIndex
id: channelContextMenu
width: 175
2020-08-04 21:09:24 +00:00
subMenuIcons: [
{
source: Qt.resolvedUrl("../../../img/bell.svg"),
width: 13,
height: 13
},
{
source: Qt.resolvedUrl("../../../img/fetch.svg"),
width: 13,
height: 13
}
]
2020-08-03 19:05:49 +00:00
function openMenu(channelIndex) {
channelContextMenu.channelIndex = channelIndex
channelContextMenu.popup()
}
Action {
text: qsTr("View Group")
icon.source: "../../../img/group.svg"
icon.width: 13
icon.height: 13
onTriggered: console.log('TODO View group')
}
2020-08-04 21:09:24 +00:00
Separator {}
PopupMenu {
hasArrow: false
title: qsTr("Mute Chat")
// TODO implement mute chat in Model and call it here
Action { text: qsTr("15 minutes"); icon.width: 0; }
Action { text: qsTr("1 hour"); icon.width: 0; }
Action { text: qsTr("8 hours"); icon.width: 0; }
Action { text: qsTr("24 hours"); icon.width: 0; }
Action { text: qsTr("Until I turn it back on"); icon.width: 0; }
2020-08-03 19:05:49 +00:00
}
Action {
text: qsTr("Mark as Read")
icon.source: "../../../img/check-circle.svg"
icon.width: 13
icon.height: 13
onTriggered: {
chatsModel.markAllChannelMessagesReadByIndex(channelContextMenu.channelIndex)
}
}
2020-08-04 21:09:24 +00:00
PopupMenu {
hasArrow: false
title: qsTr("Fetch Messages")
// TODO call fetch for the wanted duration
Action { text: qsTr("Last 24 hours"); icon.width: 0; }
Action { text: qsTr("Last 2 days"); icon.width: 0; }
Action { text: qsTr("Last 3 days"); icon.width: 0; }
Action { text: qsTr("Last 7 days"); icon.width: 0; }
2020-08-03 19:05:49 +00:00
}
Action {
text: qsTr("Clear History")
icon.source: "../../../img/close.svg"
icon.width: 13
icon.height: 13
onTriggered: chatsModel.clearChatHistoryByIndex(channelContextMenu.channelIndex)
}
2020-08-04 21:09:24 +00:00
Separator {}
2020-08-03 19:05:49 +00:00
Action {
text: qsTr("Leave Group")
icon.source: "../../../img/leave_chat.svg"
icon.width: 13
icon.height: 13
onTriggered: chatsModel.leaveChatByIndex(channelContextMenu.channelIndex)
}
}
Connections {
target: chatsModel.chats
onDataChanged: {
// If the current active channel receives messages and changes its position,
// refresh the currentIndex accordingly
if(chatsModel.activeChannelIndex !== chatGroupsListView.currentIndex){
chatGroupsListView.currentIndex = chatsModel.activeChannelIndex
2020-05-28 14:58:25 +00:00
}
}
2020-05-28 11:06:17 +00:00
}
Connections {
target: chatsModel
onActiveChannelChanged: {
chatGroupsListView.currentIndex = chatsModel.activeChannelIndex
2020-07-10 22:22:39 +00:00
SelectedMessage.reset();
chatColumn.isReply = false;
}
}
2020-06-17 19:18:31 +00:00
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/