2020-12-11 20:29:46 +00:00
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
import QtQuick.Controls 2.13
|
2021-07-02 12:34:01 +00:00
|
|
|
|
import QtQuick.Dialogs 1.2
|
2021-02-10 20:37:17 +00:00
|
|
|
|
import QtGraphicalEffects 1.13
|
2020-12-11 20:29:46 +00:00
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
import "../../../imports"
|
|
|
|
|
import "../../../shared"
|
|
|
|
|
import "../../../shared/status"
|
2021-07-06 09:42:51 +00:00
|
|
|
|
import "./components"
|
2020-12-11 20:38:10 +00:00
|
|
|
|
import "./CommunityComponents"
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
2021-07-22 14:53:19 +00:00
|
|
|
|
id: root
|
|
|
|
|
width: 304
|
|
|
|
|
height: parent.height
|
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
// TODO unhardcode
|
2021-07-02 12:34:01 +00:00
|
|
|
|
property int chatGroupsListViewCount: communityChatListAndCategories.chatList.count
|
2021-06-02 19:43:33 +00:00
|
|
|
|
property Component pinnedMessagesPopupComponent
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
StatusChatInfoToolBar {
|
2020-12-11 20:29:46 +00:00
|
|
|
|
id: communityHeader
|
|
|
|
|
anchors.top: parent.top
|
2021-07-02 12:34:01 +00:00
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
|
|
chatInfoButton.title: chatsModel.communities.activeCommunity.name
|
|
|
|
|
chatInfoButton.subTitle: chatsModel.communities.activeCommunity.nbMembers === 1 ?
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "1 Member"
|
|
|
|
|
qsTrId("1-member") :
|
|
|
|
|
//% "%1 Members"
|
|
|
|
|
qsTrId("-1-members").arg(chatsModel.communities.activeCommunity.nbMembers)
|
2021-07-02 12:34:01 +00:00
|
|
|
|
chatInfoButton.image.source: chatsModel.communities.activeCommunity.thumbnailImage
|
|
|
|
|
chatInfoButton.icon.color: chatsModel.communities.activeCommunity.communityColor
|
2021-07-16 08:36:34 +00:00
|
|
|
|
menuButton.visible: chatsModel.communities.activeCommunity.admin && chatsModel.communities.activeCommunity.canManageUsers
|
2021-07-16 12:36:27 +00:00
|
|
|
|
chatInfoButton.onClicked: openPopup(communityProfilePopup, {
|
|
|
|
|
community: chatsModel.communities.activeCommunity
|
|
|
|
|
})
|
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
popupMenu: StatusPopupMenu {
|
|
|
|
|
StatusMenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Create channel"
|
|
|
|
|
text: qsTrId("create-channel")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
icon.name: "channel"
|
|
|
|
|
enabled: chatsModel.communities.activeCommunity.admin
|
|
|
|
|
onTriggered: openPopup(createChannelPopup, {communityId: chatsModel.communities.activeCommunity.id})
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
StatusMenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Create category"
|
|
|
|
|
text: qsTrId("create-category")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
icon.name: "channel-category"
|
|
|
|
|
enabled: chatsModel.communities.activeCommunity.admin
|
|
|
|
|
onTriggered: openPopup(createCategoryPopup, {communityId: chatsModel.communities.activeCommunity.id})
|
|
|
|
|
}
|
2021-05-04 18:39:36 +00:00
|
|
|
|
|
2021-07-16 08:36:34 +00:00
|
|
|
|
StatusMenuSeparator {}
|
2021-05-04 18:39:36 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
StatusMenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Invite people"
|
|
|
|
|
text: qsTrId("invite-people")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
icon.name: "share-ios"
|
|
|
|
|
enabled: chatsModel.communities.activeCommunity.canManageUsers
|
2021-07-21 09:49:03 +00:00
|
|
|
|
onTriggered: openPopup(inviteFriendsToCommunityPopup, {
|
|
|
|
|
community: chatsModel.communities.activeCommunity
|
|
|
|
|
})
|
2021-07-02 12:34:01 +00:00
|
|
|
|
}
|
2021-05-04 18:39:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-11 19:06:39 +00:00
|
|
|
|
Loader {
|
2021-07-02 12:34:01 +00:00
|
|
|
|
id: membershipRequests
|
2021-02-10 20:37:17 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
property int nbRequests: chatsModel.communities.activeCommunity.communityMembershipRequests.nbRequests
|
|
|
|
|
|
|
|
|
|
anchors.top: communityHeader.bottom
|
|
|
|
|
anchors.topMargin: active ? 8 : 0
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
|
|
active: chatsModel.communities.activeCommunity.admin && nbRequests > 0
|
2021-07-20 09:50:36 +00:00
|
|
|
|
height: nbRequests > 0 ? 64 : 0
|
2021-02-11 19:06:39 +00:00
|
|
|
|
sourceComponent: Component {
|
2021-07-02 12:34:01 +00:00
|
|
|
|
StatusContactRequestsIndicatorListItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Membership requests"
|
|
|
|
|
title: qsTrId("membership-requests")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
requestsCount: membershipRequests.nbRequests
|
2021-07-20 09:50:36 +00:00
|
|
|
|
sensor.onClicked: openPopup(membershipRequestPopup)
|
2021-07-02 12:34:01 +00:00
|
|
|
|
}
|
2021-02-10 20:37:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
ScrollView {
|
|
|
|
|
id: chatGroupsContainer
|
2021-07-02 12:34:01 +00:00
|
|
|
|
anchors.top: membershipRequests.bottom
|
2020-12-11 20:29:46 +00:00
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
anchors.bottom: parent.bottom
|
2021-07-02 12:34:01 +00:00
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
leftPadding: Style.current.halfPadding
|
|
|
|
|
rightPadding: Style.current.halfPadding
|
2021-07-02 12:34:01 +00:00
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
clip: true
|
2021-07-02 12:34:01 +00:00
|
|
|
|
contentHeight: communityChatListAndCategories.height
|
|
|
|
|
+ emptyViewAndSuggestionsLoader.height
|
|
|
|
|
+ backUpBannerLoader.height
|
|
|
|
|
+ 16
|
|
|
|
|
|
|
|
|
|
StatusChatListAndCategories {
|
|
|
|
|
id: communityChatListAndCategories
|
|
|
|
|
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
width: root.width
|
|
|
|
|
height: {
|
|
|
|
|
if (!emptyViewAndSuggestionsLoader.active &&
|
|
|
|
|
!backUpBannerLoader.active) {
|
|
|
|
|
return implicitHeight > (root.height - 82) ? implicitHeight + 8 : root.height - 82
|
|
|
|
|
}
|
|
|
|
|
return implicitHeight
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-28 12:40:51 +00:00
|
|
|
|
draggableItems: true
|
2021-07-02 12:34:01 +00:00
|
|
|
|
chatList.model: chatsModel.communities.activeCommunity.chats
|
2021-07-28 12:40:51 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
categoryList.model: chatsModel.communities.activeCommunity.categories
|
|
|
|
|
|
|
|
|
|
showCategoryActionButtons: chatsModel.communities.activeCommunity.admin
|
2021-07-16 08:36:34 +00:00
|
|
|
|
showPopupMenu: chatsModel.communities.activeCommunity.admin && chatsModel.communities.activeCommunity.canManageUsers
|
2021-07-02 12:34:01 +00:00
|
|
|
|
selectedChatId: chatsModel.channelView.activeChannel.id
|
|
|
|
|
|
|
|
|
|
onChatItemSelected: chatsModel.channelView.setActiveChannel(id)
|
|
|
|
|
onChatItemUnmuted: chatsModel.channelView.unmuteChatItem(id)
|
2021-07-28 12:40:51 +00:00
|
|
|
|
onChatItemReordered: function (categoryId, chatId, from, to) {
|
|
|
|
|
chatsModel.communities.reorderCommunityChannel(chatsModel.communities.activeCommunity.id, categoryId, chatId, to);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
onCategoryAddButtonClicked: openPopup(createChannelPopup, {
|
|
|
|
|
communityId: chatsModel.communities.activeCommunity.id,
|
|
|
|
|
categoryId: id
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
popupMenu: StatusPopupMenu {
|
|
|
|
|
StatusMenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Create channel"
|
|
|
|
|
text: qsTrId("create-channel")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
icon.name: "channel"
|
|
|
|
|
enabled: chatsModel.communities.activeCommunity.admin
|
|
|
|
|
onTriggered: openPopup(createChannelPopup, {communityId: chatsModel.communities.activeCommunity.id})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusMenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Create category"
|
|
|
|
|
text: qsTrId("create-category")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
icon.name: "channel-category"
|
|
|
|
|
enabled: chatsModel.communities.activeCommunity.admin
|
|
|
|
|
onTriggered: openPopup(createCategoryPopup, {communityId: chatsModel.communities.activeCommunity.id})
|
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
StatusMenuSeparator {}
|
2021-06-25 09:13:54 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
StatusMenuItem {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Invite people"
|
|
|
|
|
text: qsTrId("invite-people")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
icon.name: "share-ios"
|
|
|
|
|
enabled: chatsModel.communities.activeCommunity.canManageUsers
|
2021-07-21 09:49:03 +00:00
|
|
|
|
onTriggered: openPopup(inviteFriendsToCommunityPopup, {
|
|
|
|
|
community: chatsModel.communities.activeCommunity
|
|
|
|
|
})
|
2021-07-02 12:34:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
categoryPopupMenu: StatusPopupMenu {
|
|
|
|
|
|
|
|
|
|
property var categoryItem
|
|
|
|
|
|
|
|
|
|
openHandler: function (id) {
|
|
|
|
|
categoryItem = chatsModel.communities.activeCommunity.getCommunityCategoryItemById(id)
|
|
|
|
|
}
|
2021-06-25 09:13:54 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
StatusMenuItem {
|
|
|
|
|
enabled: chatsModel.communities.activeCommunity.admin
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Edit Category"
|
|
|
|
|
text: qsTrId("edit-category")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
icon.name: "edit"
|
|
|
|
|
onTriggered: {
|
|
|
|
|
openPopup(createCategoryPopup, {
|
|
|
|
|
communityId: chatsModel.communities.activeCommunity.id,
|
|
|
|
|
isEdit: true,
|
|
|
|
|
categoryId: categoryItem.id,
|
|
|
|
|
categoryName: categoryItem.name
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-25 09:13:54 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
StatusMenuSeparator {
|
|
|
|
|
visible: chatsModel.communities.activeCommunity.admin
|
|
|
|
|
}
|
2021-06-25 09:13:54 +00:00
|
|
|
|
|
2021-07-02 12:34:01 +00:00
|
|
|
|
StatusMenuItem {
|
|
|
|
|
enabled: chatsModel.communities.activeCommunity.admin
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Delete Category"
|
|
|
|
|
text: qsTrId("delete-category")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
icon.name: "delete"
|
|
|
|
|
type: StatusMenuItem.Type.Danger
|
|
|
|
|
onTriggered: {
|
|
|
|
|
openPopup(deleteCategoryConfirmationDialogComponent, {
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Delete %1 category"
|
|
|
|
|
title: qsTrId("delete--1-category").arg(categoryItem.name),
|
|
|
|
|
//% "Are you sure you want to delete %1 category? Channels inside the category won’t be deleted."
|
|
|
|
|
confirmationText: qsTrId("are-you-sure-you-want-to-delete--1-category--channels-inside-the-category-won-t-be-deleted-")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
.arg(categoryItem.name),
|
|
|
|
|
categoryId: categoryItem.id
|
|
|
|
|
})
|
|
|
|
|
}
|
2021-06-25 09:13:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
|
chatListPopupMenu: ChatContextMenu {
|
2021-07-02 12:34:01 +00:00
|
|
|
|
openHandler: function (id) {
|
|
|
|
|
chatItem = chatsModel.channelView.getChatItemById(id)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-16 15:16:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-28 19:03:41 +00:00
|
|
|
|
Loader {
|
|
|
|
|
id: emptyViewAndSuggestionsLoader
|
2021-04-29 14:48:16 +00:00
|
|
|
|
active: chatsModel.communities.activeCommunity.admin && !appSettings.hiddenCommunityWelcomeBanners.includes(chatsModel.communities.activeCommunity.id)
|
2020-12-11 20:29:46 +00:00
|
|
|
|
width: parent.width
|
2021-04-28 19:03:41 +00:00
|
|
|
|
height: active ? item.height : 0
|
2021-07-02 12:34:01 +00:00
|
|
|
|
anchors.top: communityChatListAndCategories.bottom
|
2021-04-28 19:03:41 +00:00
|
|
|
|
anchors.topMargin: active ? Style.current.padding : 0
|
|
|
|
|
sourceComponent: Component {
|
|
|
|
|
CommunityWelcomeBanner {}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-02 12:34:01 +00:00
|
|
|
|
|
2021-04-28 19:03:41 +00:00
|
|
|
|
Loader {
|
|
|
|
|
id: backUpBannerLoader
|
2021-04-29 14:48:16 +00:00
|
|
|
|
active: chatsModel.communities.activeCommunity.admin && !appSettings.hiddenCommunityBackUpBanners.includes(chatsModel.communities.activeCommunity.id)
|
2021-04-28 19:03:41 +00:00
|
|
|
|
width: parent.width
|
|
|
|
|
height: active ? item.height : 0
|
|
|
|
|
anchors.top: emptyViewAndSuggestionsLoader.bottom
|
|
|
|
|
anchors.topMargin: active ? Style.current.padding : 0
|
|
|
|
|
sourceComponent: Component {
|
2021-06-29 17:42:13 +00:00
|
|
|
|
Item {
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: backupBanner.height
|
|
|
|
|
|
|
|
|
|
BackUpCommuntyBanner {
|
|
|
|
|
id: backupBanner
|
|
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: backupBanner
|
|
|
|
|
acceptedButtons: Qt.RightButton
|
|
|
|
|
onClicked: {
|
|
|
|
|
/* Prevents sending events to the component beneath
|
|
|
|
|
if Right Mouse Button is clicked. */
|
|
|
|
|
mouse.accepted = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-28 19:03:41 +00:00
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-02 12:34:01 +00:00
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: createChannelPopup
|
|
|
|
|
CreateChannelPopup {
|
2021-07-07 12:45:11 +00:00
|
|
|
|
anchors.centerIn: parent
|
2021-07-02 12:34:01 +00:00
|
|
|
|
pinnedMessagesPopupComponent: root.pinnedMessagesPopupComponent
|
|
|
|
|
onClosed: {
|
|
|
|
|
destroy()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: createCategoryPopup
|
|
|
|
|
CreateCategoryPopup {
|
2021-07-09 10:09:03 +00:00
|
|
|
|
anchors.centerIn: parent
|
2021-07-02 12:34:01 +00:00
|
|
|
|
onClosed: {
|
|
|
|
|
destroy()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: deleteCategoryConfirmationDialogComponent
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
|
property string categoryId
|
|
|
|
|
btnType: "warn"
|
|
|
|
|
height: 216
|
|
|
|
|
showCancelButton: true
|
|
|
|
|
onClosed: {
|
|
|
|
|
destroy()
|
|
|
|
|
}
|
|
|
|
|
onCancelButtonClicked: {
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
onConfirmButtonClicked: function(){
|
|
|
|
|
const error = chatsModel.communities.deleteCommunityCategory(chatsModel.communities.activeCommunity.id, categoryId)
|
|
|
|
|
if (error) {
|
|
|
|
|
creatingError.text = error
|
|
|
|
|
return creatingError.open()
|
|
|
|
|
}
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
|
id: deleteError
|
2021-07-16 20:22:50 +00:00
|
|
|
|
//% "Error deleting the category"
|
|
|
|
|
title: qsTrId("error-deleting-the-category")
|
2021-07-02 12:34:01 +00:00
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-20 09:50:36 +00:00
|
|
|
|
Component {
|
2021-07-02 12:34:01 +00:00
|
|
|
|
id: membershipRequestPopup
|
2021-07-20 09:50:36 +00:00
|
|
|
|
MembershipRequestsPopup {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
onClosed: {
|
|
|
|
|
destroy()
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-02 12:34:01 +00:00
|
|
|
|
}
|
2021-07-20 09:50:36 +00:00
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
|
Designer {
|
|
|
|
|
D{i:0;autoSize:true;formeditorColor:"#ffffff";height:480;width:640}
|
|
|
|
|
}
|
|
|
|
|
##^##*/
|