2024-10-15 21:26:12 +02:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2021-09-28 18:04:06 +03:00
|
|
|
|
2024-11-28 09:15:34 -05:00
|
|
|
import StatusQ 0.1
|
2021-10-26 16:21:08 +02:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-25 21:37:44 +02:00
|
|
|
import StatusQ.Controls 0.1
|
2024-11-06 21:08:22 +01:00
|
|
|
import StatusQ.Core 0.1
|
2021-10-25 21:37:44 +02:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2024-11-06 21:08:22 +01:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2021-10-25 21:37:44 +02:00
|
|
|
|
2021-09-28 18:04:06 +03:00
|
|
|
import utils 1.0
|
2021-10-26 16:21:08 +02:00
|
|
|
|
2024-10-22 14:39:42 +02:00
|
|
|
import shared.controls 1.0
|
2021-10-28 00:27:49 +03:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
2024-10-22 14:39:42 +02:00
|
|
|
import shared.stores 1.0 as SharedStores
|
|
|
|
import shared.views 1.0
|
2022-07-06 15:27:04 -04:00
|
|
|
import shared.views.chat 1.0
|
2021-10-06 11:16:39 +02:00
|
|
|
|
2024-12-18 21:00:08 +01:00
|
|
|
import AppLayouts.Profile.stores 1.0
|
|
|
|
import AppLayouts.Profile.panels 1.0
|
|
|
|
import AppLayouts.Profile.popups 1.0
|
2020-05-27 17:28:25 -04:00
|
|
|
|
2022-05-07 13:45:15 +02:00
|
|
|
SettingsContentBase {
|
2021-10-06 11:16:39 +02:00
|
|
|
id: root
|
2024-10-22 14:39:42 +02:00
|
|
|
|
2021-12-31 13:29:51 +01:00
|
|
|
property ContactsStore contactsStore
|
2024-10-22 14:39:42 +02:00
|
|
|
property SharedStores.UtilsStore utilsStore
|
|
|
|
|
2024-12-18 21:00:08 +01:00
|
|
|
required property var mutualContactsModel
|
|
|
|
required property var blockedContactsModel
|
|
|
|
required property var pendingContactsModel
|
|
|
|
required property int pendingReceivedContactsCount
|
2024-11-28 09:15:34 -05:00
|
|
|
|
2020-07-24 13:27:26 +02:00
|
|
|
property alias searchStr: searchBox.text
|
2022-03-28 16:42:26 +02:00
|
|
|
|
2022-10-28 10:24:23 +02:00
|
|
|
titleRowComponentLoader.sourceComponent: StatusButton {
|
2022-10-26 16:00:40 -04:00
|
|
|
objectName: "ContactsView_ContactRequest_Button"
|
2022-10-28 10:24:23 +02:00
|
|
|
text: qsTr("Send contact request to chat key")
|
2024-12-18 21:00:08 +01:00
|
|
|
onClicked: sendContactRequestComponent.createObject(root).open()
|
2022-10-28 10:24:23 +02:00
|
|
|
}
|
2022-05-07 13:45:15 +02:00
|
|
|
|
2024-11-07 15:29:28 +01:00
|
|
|
function openContextMenu(model, pubKey) {
|
|
|
|
const entry = ModelUtils.getByKey(model, "pubKey", pubKey)
|
|
|
|
|
|
|
|
const profileType = Utils.getProfileType(entry.isCurrentUser, false, entry.isBlocked)
|
|
|
|
const contactType = Utils.getContactType(entry.contactRequest, entry.isContact)
|
2024-09-06 11:55:44 -04:00
|
|
|
|
2024-11-07 15:29:28 +01:00
|
|
|
const params = {
|
|
|
|
pubKey, profileType, contactType,
|
|
|
|
compressedPubKey: entry.compressedPubKey,
|
2024-11-07 11:43:06 +01:00
|
|
|
emojiHash: root.utilsStore.getEmojiHash(pubKey),
|
2024-11-07 15:29:28 +01:00
|
|
|
displayName: entry.preferredDisplayName,
|
|
|
|
userIcon: entry.icon,
|
|
|
|
colorHash: entry.colorHash,
|
|
|
|
colorId: entry.colorId,
|
|
|
|
trustStatus: entry.trustStatus,
|
|
|
|
onlineStatus: entry.onlineStatus,
|
|
|
|
ensVerified: entry.isEnsVerified,
|
|
|
|
hasLocalNickname: !!entry.localNickname
|
|
|
|
}
|
2022-07-06 15:27:04 -04:00
|
|
|
|
2024-11-07 15:29:28 +01:00
|
|
|
Global.openMenu(contactContextMenuComponent, this, params)
|
2024-11-06 21:08:22 +01:00
|
|
|
}
|
|
|
|
|
2024-12-18 21:00:08 +01:00
|
|
|
headerComponents: ColumnLayout {
|
2022-08-18 17:41:02 +03:00
|
|
|
width: root.contentWidth
|
2024-12-18 21:00:08 +01:00
|
|
|
spacing: Theme.padding
|
2020-07-21 17:03:22 -04:00
|
|
|
|
2022-05-23 14:45:29 +03:00
|
|
|
StatusTabBar {
|
2022-03-15 11:55:18 -04:00
|
|
|
id: contactsTabBar
|
2024-12-18 21:00:08 +01:00
|
|
|
Layout.fillWidth: true
|
2022-09-12 12:54:07 +03:00
|
|
|
|
2022-03-15 11:55:18 -04:00
|
|
|
StatusTabButton {
|
2024-12-18 21:00:08 +01:00
|
|
|
readonly property int panelUsage: Constants.contactsPanelUsage.mutualContacts
|
|
|
|
|
2022-05-23 14:45:29 +03:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Contacts")
|
2021-01-14 15:09:07 -05:00
|
|
|
}
|
2022-03-15 11:55:18 -04:00
|
|
|
StatusTabButton {
|
2024-12-18 21:00:08 +01:00
|
|
|
readonly property int panelUsage: Constants.contactsPanelUsage.pendingContacts
|
|
|
|
|
2022-10-26 16:00:40 -04:00
|
|
|
objectName: "ContactsView_PendingRequest_Button"
|
2022-05-23 14:45:29 +03:00
|
|
|
width: implicitWidth
|
2024-12-18 21:00:08 +01:00
|
|
|
enabled: !!root.pendingContactsModel && !root.pendingContactsModel.ModelCount.empty
|
2022-05-23 14:45:29 +03:00
|
|
|
text: qsTr("Pending Requests")
|
2024-12-18 21:00:08 +01:00
|
|
|
badge.value: root.pendingReceivedContactsCount
|
2022-03-15 11:55:18 -04:00
|
|
|
}
|
|
|
|
StatusTabButton {
|
2024-12-18 21:00:08 +01:00
|
|
|
readonly property int panelUsage: Constants.contactsPanelUsage.blockedContacts
|
|
|
|
|
2024-07-18 17:57:24 +07:00
|
|
|
objectName: "ContactsView_Blocked_Button"
|
2022-05-23 14:45:29 +03:00
|
|
|
width: implicitWidth
|
2024-12-18 21:00:08 +01:00
|
|
|
enabled: !!root.blockedContactsModel && !root.blockedContactsModel.ModelCount.empty
|
2022-05-23 14:45:29 +03:00
|
|
|
text: qsTr("Blocked")
|
2021-01-14 15:09:07 -05:00
|
|
|
}
|
2020-07-24 13:27:26 +02:00
|
|
|
}
|
|
|
|
|
2024-12-18 21:00:08 +01:00
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
|
|
|
Layout.fillWidth: true
|
|
|
|
placeholderText: qsTr("Search by name or chat key")
|
|
|
|
}
|
|
|
|
}
|
2024-11-28 09:15:34 -05:00
|
|
|
|
2024-12-18 21:00:08 +01:00
|
|
|
ContactsListPanel {
|
|
|
|
id: contactsListPanel
|
|
|
|
width: root.contentWidth
|
|
|
|
height: root.availableHeight
|
|
|
|
|
|
|
|
panelUsage: contactsTabBar.currentItem.panelUsage
|
|
|
|
contactsModel: {
|
|
|
|
switch (panelUsage) {
|
|
|
|
case Constants.contactsPanelUsage.pendingContacts:
|
|
|
|
return root.pendingContactsModel
|
|
|
|
case Constants.contactsPanelUsage.blockedContacts:
|
|
|
|
return root.blockedContactsModel
|
|
|
|
case Constants.contactsPanelUsage.mutualContacts:
|
|
|
|
default:
|
|
|
|
return root.mutualContactsModel
|
2021-09-17 17:08:16 +02:00
|
|
|
}
|
2024-12-18 21:00:08 +01:00
|
|
|
}
|
|
|
|
section.property: {
|
|
|
|
switch (contactsListPanel.panelUsage) {
|
|
|
|
case Constants.contactsPanelUsage.pendingContacts:
|
|
|
|
return "contactRequest"
|
|
|
|
case Constants.contactsPanelUsage.mutualContacts:
|
|
|
|
return "isVerified"
|
|
|
|
case Constants.contactsPanelUsage.blockedContacts:
|
|
|
|
default:
|
|
|
|
return ""
|
2022-03-24 21:55:22 +01:00
|
|
|
}
|
2024-12-18 21:00:08 +01:00
|
|
|
}
|
|
|
|
section.delegate: SectionComponent {
|
|
|
|
text: {
|
|
|
|
switch (contactsListPanel.panelUsage) {
|
|
|
|
case Constants.contactsPanelUsage.pendingContacts:
|
|
|
|
return section === `${Constants.ContactRequestState.Received}` ? qsTr("Received") : qsTr("Sent")
|
|
|
|
case Constants.contactsPanelUsage.mutualContacts:
|
|
|
|
return section === "true" ? qsTr("Trusted Contacts") : qsTr("Contacts")
|
|
|
|
case Constants.contactsPanelUsage.blockedContacts:
|
|
|
|
default:
|
|
|
|
return ""
|
2022-08-18 17:41:02 +03:00
|
|
|
}
|
2021-01-14 15:09:07 -05:00
|
|
|
}
|
2020-09-17 10:47:14 +02:00
|
|
|
}
|
2024-12-18 21:00:08 +01:00
|
|
|
section.labelPositioning: ViewSection.InlineLabels | ViewSection.CurrentLabelAtStart
|
2020-09-17 10:47:14 +02:00
|
|
|
|
2024-12-18 21:00:08 +01:00
|
|
|
header: NoFriendsRectangle {
|
|
|
|
width: ListView.view.width
|
|
|
|
visible: ListView.view.count === 0
|
|
|
|
inviteButtonVisible: searchBox.text === ""
|
2021-01-14 15:09:07 -05:00
|
|
|
}
|
2020-06-16 14:04:56 -04:00
|
|
|
|
2024-12-18 21:00:08 +01:00
|
|
|
searchString: searchBox.text
|
|
|
|
onOpenContactContextMenu: root.openContextMenu(contactsModel, publicKey)
|
|
|
|
onSendMessageActionTriggered: root.contactsStore.joinPrivateChat(publicKey)
|
|
|
|
onContactRequestAccepted: root.contactsStore.acceptContactRequest(publicKey, "")
|
|
|
|
onContactRequestRejected: root.contactsStore.dismissContactRequest(publicKey, "")
|
|
|
|
|
2023-05-23 14:46:16 +02:00
|
|
|
Component {
|
2024-12-18 21:00:08 +01:00
|
|
|
id: sendContactRequestComponent
|
2023-05-23 14:46:16 +02:00
|
|
|
SendContactRequestModal {
|
2022-05-07 13:45:15 +02:00
|
|
|
contactsStore: root.contactsStore
|
2023-08-01 14:32:03 +02:00
|
|
|
onClosed: destroy()
|
2022-03-28 16:42:26 +02:00
|
|
|
}
|
|
|
|
}
|
2024-12-18 21:00:08 +01:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: contactContextMenuComponent
|
|
|
|
ProfileContextMenu {
|
|
|
|
id: contactContextMenu
|
|
|
|
|
|
|
|
property string pubKey
|
|
|
|
|
|
|
|
onOpenProfileClicked: Global.openProfilePopup(contactContextMenu.pubKey, null, null)
|
|
|
|
onReviewContactRequest: Global.openReviewContactRequestPopup(contactContextMenu.pubKey, null)
|
|
|
|
onSendContactRequest: Global.openContactRequestPopup(contactContextMenu.pubKey, null)
|
|
|
|
onEditNickname: Global.openNicknamePopupRequested(contactContextMenu.pubKey, null)
|
|
|
|
onUnblockContact: Global.unblockContactRequested(contactContextMenu.pubKey)
|
|
|
|
onMarkAsUntrusted: Global.markAsUntrustedRequested(contactContextMenu.pubKey)
|
|
|
|
onRemoveContact: Global.removeContactRequested(contactContextMenu.pubKey)
|
|
|
|
onBlockContact: Global.blockContactRequested(contactContextMenu.pubKey)
|
|
|
|
|
|
|
|
onCreateOneToOneChat: root.contactsStore.joinPrivateChat(contactContextMenu.pubKey)
|
|
|
|
onRemoveTrustStatus: root.contactsStore.removeTrustStatus(contactContextMenu.pubKey)
|
|
|
|
onRemoveNickname: root.contactsStore.changeContactNickname(contactContextMenu.pubKey, "",
|
|
|
|
contactContextMenu.displayName, true)
|
|
|
|
onMarkAsTrusted: Global.openMarkAsIDVerifiedPopup(contactContextMenu.pubKey, null)
|
|
|
|
onRemoveTrustedMark: Global.openRemoveIDVerificationDialog(contactContextMenu.pubKey, null)
|
|
|
|
onClosed: destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
component SectionComponent: Rectangle {
|
|
|
|
required property string section
|
|
|
|
property alias text: sectionText.text
|
|
|
|
|
|
|
|
width: ListView.view.width
|
|
|
|
height: sectionText.implicitHeight
|
|
|
|
color: Theme.palette.statusListItem.backgroundColor
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: sectionText
|
|
|
|
width: parent.width
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
topPadding: Theme.halfPadding
|
|
|
|
bottomPadding: Theme.halfPadding
|
|
|
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: Theme.additionalTextSize
|
|
|
|
font.weight: Font.Medium
|
|
|
|
elide: Text.ElideRight
|
|
|
|
}
|
2022-03-28 16:42:26 +02:00
|
|
|
}
|
2020-06-16 14:04:56 -04:00
|
|
|
}
|