2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-06-24 03:23:49 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
2021-10-01 15:58:36 +00:00
|
|
|
|
|
|
|
import "../panels"
|
|
|
|
import "../popups"
|
|
|
|
import "../popups/community"
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2021-06-30 14:17:05 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-07-26 13:34:19 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2021-06-30 14:17:05 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
Item {
|
2021-10-21 22:39:53 +00:00
|
|
|
id: root
|
2021-07-22 14:53:19 +00:00
|
|
|
width: 304
|
|
|
|
height: parent.height
|
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
property var store
|
2021-06-30 14:17:05 +00:00
|
|
|
property int chatGroupsListViewCount: channelList.chatListItems.count
|
2021-07-20 15:22:09 +00:00
|
|
|
signal openProfileClicked()
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2021-08-18 14:43:59 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
appMain.openContactsPopup.connect(function(){
|
|
|
|
openPopup(contactRequestsPopup)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-07-15 15:50:50 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
//steal focus from search field
|
2021-07-26 13:34:19 +00:00
|
|
|
actionButton.forceActiveFocus();
|
2021-07-15 15:50:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-30 14:17:05 +00:00
|
|
|
StatusNavigationPanelHeadline {
|
|
|
|
id: headline
|
2020-05-27 18:40:58 +00:00
|
|
|
anchors.top: parent.top
|
2021-06-30 14:17:05 +00:00
|
|
|
anchors.topMargin: 16
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Chat"
|
|
|
|
text: qsTrId("chat")
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
2021-07-26 13:34:19 +00:00
|
|
|
Item {
|
|
|
|
id: searchInputWrapper
|
2021-06-30 14:17:05 +00:00
|
|
|
anchors.top: headline.bottom
|
2021-07-26 13:34:19 +00:00
|
|
|
anchors.topMargin: 16
|
|
|
|
width: parent.width
|
|
|
|
height: searchInput.height
|
|
|
|
|
2021-08-16 08:54:20 +00:00
|
|
|
Item {
|
2021-07-26 13:34:19 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: actionButton.left
|
|
|
|
anchors.leftMargin: 16
|
|
|
|
anchors.rightMargin: 16
|
2021-08-16 08:54:20 +00:00
|
|
|
implicitHeight: searchInput.height
|
|
|
|
implicitWidth: searchInput.width
|
|
|
|
|
|
|
|
StatusBaseInput {
|
|
|
|
id: searchInput
|
2021-09-08 07:41:50 +00:00
|
|
|
implicitHeight: 36
|
2021-08-16 08:54:20 +00:00
|
|
|
width: parent.width
|
2021-09-08 07:41:50 +00:00
|
|
|
topPadding: 9
|
2021-08-16 08:54:20 +00:00
|
|
|
//% "Search"
|
|
|
|
placeholderText: qsTrId("search")
|
|
|
|
icon.name: "search"
|
|
|
|
}
|
2021-07-26 13:34:19 +00:00
|
|
|
|
2021-08-16 08:54:20 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: searchPopup.open()
|
2021-07-26 13:34:19 +00:00
|
|
|
}
|
2021-07-15 15:50:50 +00:00
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2021-07-26 13:34:19 +00:00
|
|
|
StatusRoundButton {
|
|
|
|
id: actionButton
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
|
|
|
|
type: StatusRoundButton.Type.Secondary
|
|
|
|
icon.name: "add"
|
|
|
|
state: "default"
|
|
|
|
|
2021-09-27 10:30:51 +00:00
|
|
|
onClicked: {
|
|
|
|
chatContextMenu.opened ?
|
|
|
|
chatContextMenu.close() :
|
|
|
|
chatContextMenu.popup(actionButton.width-chatContextMenu.width, actionButton.height + 4)
|
|
|
|
}
|
2021-07-26 13:34:19 +00:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "default"
|
|
|
|
PropertyChanges {
|
|
|
|
target: actionButton
|
|
|
|
icon.rotation: 0
|
|
|
|
highlighted: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "pressed"
|
|
|
|
PropertyChanges {
|
|
|
|
target: actionButton
|
|
|
|
icon.rotation: 45
|
|
|
|
highlighted: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
from: "default"
|
|
|
|
to: "pressed"
|
|
|
|
|
|
|
|
RotationAnimation {
|
|
|
|
duration: 150
|
|
|
|
direction: RotationAnimation.Clockwise
|
|
|
|
easing.type: Easing.InCubic
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Transition {
|
|
|
|
from: "pressed"
|
|
|
|
to: "default"
|
|
|
|
RotationAnimation {
|
|
|
|
duration: 150
|
|
|
|
direction: RotationAnimation.Counterclockwise
|
|
|
|
easing.type: Easing.OutCubic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
StatusPopupMenu {
|
|
|
|
id: chatContextMenu
|
2021-10-01 15:58:36 +00:00
|
|
|
closePolicy: Popup.CloseOnReleaseOutsideParent | Popup.CloseOnEscape
|
2021-07-26 13:34:19 +00:00
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
actionButton.state = "pressed"
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
actionButton.state = "default"
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Start new chat"
|
|
|
|
text: qsTrId("start-new-chat")
|
2021-07-26 13:34:19 +00:00
|
|
|
icon.name: "private-chat"
|
|
|
|
onTriggered: openPopup(privateChatPopupComponent)
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Start group chat"
|
|
|
|
text: qsTrId("start-group-chat")
|
2021-07-26 13:34:19 +00:00
|
|
|
icon.name: "group-chat"
|
|
|
|
onTriggered: openPopup(groupChatPopupComponent)
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Join public chat"
|
|
|
|
text: qsTrId("new-public-group-chat")
|
2021-07-26 13:34:19 +00:00
|
|
|
icon.name: "public-chat"
|
|
|
|
onTriggered: openPopup(publicChatPopupComponent)
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-07-30 16:02:22 +00:00
|
|
|
//% "Communities"
|
|
|
|
text: qsTrId("communities")
|
2021-07-26 13:34:19 +00:00
|
|
|
icon.name: "communities"
|
|
|
|
onTriggered: openPopup(communitiesPopupComponent)
|
2021-10-20 09:50:50 +00:00
|
|
|
enabled: localAccountSensitiveSettings.communitiesEnabled
|
2021-07-26 13:34:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusContactRequestsIndicatorListItem {
|
|
|
|
id: contactRequests
|
|
|
|
|
2021-11-15 15:15:21 +00:00
|
|
|
property int nbRequests: root.store.contactRequests.count
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2021-07-26 13:34:19 +00:00
|
|
|
anchors.top: searchInputWrapper.bottom
|
2021-06-30 14:17:05 +00:00
|
|
|
anchors.topMargin: visible ? Style.current.padding : 0
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
visible: nbRequests > 0
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Contact requests"
|
|
|
|
title: qsTrId("contact-requests")
|
2021-06-30 14:17:05 +00:00
|
|
|
requestsCount: nbRequests
|
|
|
|
|
|
|
|
sensor.onClicked: openPopup(contactRequestsPopup)
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
id: chatGroupsContainer
|
|
|
|
|
2021-07-15 15:50:50 +00:00
|
|
|
width: parent.width
|
|
|
|
height: (contentHeight < (parent.height - contactRequests.height - Style.current.padding)) ? contentHeight : (parent.height - contactRequests.height - Style.current.padding)
|
2021-06-30 14:17:05 +00:00
|
|
|
anchors.top: contactRequests.bottom
|
2020-07-15 19:38:03 +00:00
|
|
|
anchors.topMargin: Style.current.padding
|
2021-10-21 22:39:53 +00:00
|
|
|
anchors.bottom: root.bottom
|
2021-08-24 09:58:55 +00:00
|
|
|
contentHeight: channelList.childrenRect.height + emptyViewAndSuggestions.childrenRect.height
|
2020-05-27 18:40:58 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-06-30 14:17:05 +00:00
|
|
|
|
|
|
|
leftPadding: Style.current.halfPadding
|
|
|
|
rightPadding: Style.current.halfPadding
|
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
StatusChatList {
|
|
|
|
id: channelList
|
|
|
|
|
|
|
|
chatNameFn: function (chatItem) {
|
|
|
|
return chatItem.chatType !== Constants.chatTypePublic ?
|
2021-07-15 15:50:50 +00:00
|
|
|
Emoji.parse(Utils.removeStatusEns(Utils.filterXSS(chatItem.name))) :
|
|
|
|
Utils.filterXSS(chatItem.name)
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
profileImageFn: function (id) {
|
|
|
|
return appMain.getProfileImage(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2021-11-15 15:15:21 +00:00
|
|
|
target: root.store.allContacts
|
2021-06-30 14:17:05 +00:00
|
|
|
onContactChanged: {
|
|
|
|
for (var i = 0; i < channelList.chatListItems.count; i++) {
|
2021-10-21 22:39:53 +00:00
|
|
|
if (!!channelList.statusChatListItems) {
|
2021-11-15 15:15:21 +00:00
|
|
|
let chatItem = !!channelList.statusChatListItems.model.items ?
|
|
|
|
channelList.statusChatListItems.model.items.get(i) : null
|
|
|
|
if (chatItem && chatItem.chatId === pubkey) {
|
2021-10-21 00:41:54 +00:00
|
|
|
let profileImage = appMain.getProfileImage(pubkey)
|
|
|
|
if (!!profileImage) {
|
|
|
|
chatItem.image.isIdenticon = false
|
|
|
|
chatItem.image.source = profileImage
|
|
|
|
}
|
|
|
|
break;
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
chatListItems.model: root.store.chatsModelInst.channelView.chats
|
|
|
|
selectedChatId: root.store.chatsModelInst.channelView.activeChannel.id
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
onChatItemSelected: root.store.chatsModelInst.channelView.setActiveChannel(id)
|
|
|
|
onChatItemUnmuted: root.store.chatsModelInst.channelView.unmuteChatItem(id)
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
popupMenu: ChatContextMenuView {
|
2021-11-03 19:35:12 +00:00
|
|
|
id: chatContextMenuView
|
2021-10-21 22:39:53 +00:00
|
|
|
store: root.store
|
2021-06-30 14:17:05 +00:00
|
|
|
openHandler: function (id) {
|
2021-11-03 19:35:12 +00:00
|
|
|
root.store.chatsModelInst.channelView.setContextChannel(id)
|
|
|
|
chatContextMenuView.chatItem = root.store.chatsModelInst.channelView.contextChannel
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-24 09:58:55 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
EmptyViewPanel {
|
2021-08-24 09:58:55 +00:00
|
|
|
id: emptyViewAndSuggestions
|
2021-10-20 09:50:50 +00:00
|
|
|
visible: !localAccountSensitiveSettings.hideChannelSuggestions
|
2021-08-24 09:58:55 +00:00
|
|
|
width: parent.width
|
|
|
|
anchors.top: channelList.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
2021-10-21 22:39:53 +00:00
|
|
|
onSuggestedMessageClicked: root.store.chatsModelInst.channelView.joinPublicChat(channel)
|
2021-08-24 09:58:55 +00:00
|
|
|
}
|
2020-05-27 18:40:58 +00:00
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: publicChatPopupComponent
|
|
|
|
PublicChatPopup {
|
2021-10-22 20:49:47 +00:00
|
|
|
onJoinPublicChat: {
|
|
|
|
root.store.chatsModelInst.channelView.joinPublicChat(name);
|
|
|
|
}
|
|
|
|
onSuggestedMessageClicked: {
|
|
|
|
root.store.chatsModelInst.channelView.joinPublicChat(channel);
|
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 20:11:56 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: groupChatPopupComponent
|
|
|
|
GroupChatPopup {
|
2021-10-27 14:43:13 +00:00
|
|
|
store: root.store
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-06-17 15:56:48 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: privateChatPopupComponent
|
|
|
|
PrivateChatPopup {
|
2021-10-22 20:49:47 +00:00
|
|
|
store: root.store
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2021-07-20 15:22:09 +00:00
|
|
|
onProfileClicked: {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.openProfileClicked();
|
2021-07-20 15:22:09 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communitiesPopupComponent
|
|
|
|
CommunitiesPopup {
|
2021-07-19 11:21:05 +00:00
|
|
|
anchors.centerIn: parent
|
2021-10-22 20:49:47 +00:00
|
|
|
communitiesList: root.store.chatsModelInst.communities.list
|
|
|
|
onSetActiveCommunity: {
|
|
|
|
root.store.chatsModelInst.communities.setActiveCommunity(id)
|
|
|
|
}
|
|
|
|
onSetObservedCommunity: {
|
|
|
|
root.store.chatsModelInst.communities.setObservedCommunity(id)
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: createCommunitiesPopupComponent
|
|
|
|
CreateCommunityPopup {
|
2021-07-16 10:11:03 +00:00
|
|
|
anchors.centerIn: parent
|
2021-10-22 20:49:47 +00:00
|
|
|
store: root.store
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-18 20:55:33 +00:00
|
|
|
Component {
|
|
|
|
id: importCommunitiesPopupComponent
|
2021-02-12 18:19:31 +00:00
|
|
|
AccessExistingCommunityPopup {
|
2021-10-22 20:49:47 +00:00
|
|
|
anchors.centerIn: parent
|
2021-11-30 14:49:36 +00:00
|
|
|
store: root.store
|
2020-12-18 20:55:33 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: communityDetailPopup
|
|
|
|
CommunityDetailPopup {
|
2021-07-19 12:25:52 +00:00
|
|
|
anchors.centerIn: parent
|
2021-10-22 20:49:47 +00:00
|
|
|
store: root.store
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 12:56:43 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 17:36:24 +00:00
|
|
|
Component {
|
|
|
|
id: contactRequestsPopup
|
|
|
|
ContactRequestsPopup {
|
2021-10-22 20:49:47 +00:00
|
|
|
store: root.store
|
2021-05-26 17:36:24 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 19:19:34 +00:00
|
|
|
|
2021-07-16 05:37:07 +00:00
|
|
|
Connections {
|
2021-10-21 22:39:53 +00:00
|
|
|
target: root.store.chatsModelInst.communities
|
2021-07-16 05:37:07 +00:00
|
|
|
onImportingCommunityStateChanged: {
|
|
|
|
if (state !== Constants.communityImported &&
|
|
|
|
state !== Constants.communityImportingInProgress &&
|
|
|
|
state !== Constants.communityImportingError)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state === Constants.communityImported)
|
|
|
|
{
|
|
|
|
if (toastMessage.uuid !== communityImportingProcessId)
|
|
|
|
return
|
|
|
|
|
|
|
|
toastMessage.close()
|
|
|
|
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Community imported"
|
|
|
|
toastMessage.title = qsTrId("community-imported")
|
2021-07-16 05:37:07 +00:00
|
|
|
toastMessage.source = ""
|
|
|
|
toastMessage.iconRotates = false
|
|
|
|
toastMessage.dissapearInMs = 4000
|
|
|
|
}
|
|
|
|
else if (state === Constants.communityImportingInProgress)
|
|
|
|
{
|
|
|
|
toastMessage.uuid = communityImportingProcessId
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Importing community is in progress"
|
|
|
|
toastMessage.title = qsTrId("importing-community-is-in-progress")
|
2021-09-28 15:04:06 +00:00
|
|
|
toastMessage.source = Style.svg("loading")
|
2021-07-16 05:37:07 +00:00
|
|
|
toastMessage.iconRotates = true
|
|
|
|
toastMessage.dissapearInMs = -1
|
|
|
|
}
|
|
|
|
else if (state === Constants.communityImportingError)
|
|
|
|
{
|
|
|
|
if (toastMessage.uuid !== communityImportingProcessId)
|
|
|
|
return
|
|
|
|
|
|
|
|
toastMessage.close()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
toastMessage.displayCloseButton = false
|
|
|
|
toastMessage.displayLink = false
|
|
|
|
toastMessage.iconColor = Style.current.primary
|
|
|
|
toastMessage.open()
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 19:19:34 +00:00
|
|
|
}
|