ContactPanel delegate made backend-independent

This commit is contained in:
Michał Cieślak 2024-10-25 15:00:32 +02:00 committed by Michał
parent 189d016694
commit 9b5b5a4a60
4 changed files with 12 additions and 34 deletions

View File

@ -1,22 +1,11 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import StatusQ.Popups 0.1 import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import utils 1.0 import utils 1.0
import shared 1.0
import shared.panels 1.0
import shared.status 1.0
import shared.views 1.0
import shared.controls.chat 1.0
import shared.controls.chat.menuItems 1.0
import AppLayouts.Profile.stores 1.0
StatusListItem { StatusListItem {
id: root id: root
@ -25,13 +14,12 @@ StatusListItem {
height: visible ? implicitHeight : 0 height: visible ? implicitHeight : 0
title: root.name title: root.name
property ContactsStore contactsStore
property string name property string name
property string publicKey property string publicKey
property string compressedPk // Needed for the tests + probably gonna be used more in the future
property string iconSource property string iconSource
property bool ensVerified
property color pubKeyColor
property var colorHash
property bool isContact: false property bool isContact: false
property bool isBlocked: false property bool isBlocked: false
@ -54,17 +42,15 @@ StatusListItem {
signal rejectionRemoved(string publicKey) signal rejectionRemoved(string publicKey)
signal textClicked(string publicKey) signal textClicked(string publicKey)
subTitle: root.ensVerified ? "" : Utils.getElidedCompressedPk(root.publicKey)
asset.width: 40 asset.width: 40
asset.height: 40 asset.height: 40
asset.color: Utils.colorForPubkey(root.publicKey) asset.color: root.pubKeyColor
asset.letterSize: asset._twoLettersSize asset.letterSize: asset._twoLettersSize
asset.charactersLen: 2 asset.charactersLen: 2
asset.name: root.iconSource asset.name: root.iconSource
asset.isLetterIdenticon: root.iconSource.toString() === "" asset.isLetterIdenticon: root.iconSource.toString() === ""
ringSettings { ringSettings {
ringSpecModel: Utils.getColorHashAsJson(root.publicKey, root.ensVerified) ringSpecModel: root.colorHash
ringPxSize: Math.max(asset.width / 24.0) ringPxSize: Math.max(asset.width / 24.0)
} }

View File

@ -13,15 +13,12 @@ import shared.panels 1.0
import "../../Chat/popups" import "../../Chat/popups"
import AppLayouts.Profile.stores 1.0
import SortFilterProxyModel 0.2 import SortFilterProxyModel 0.2
Item { Item {
id: root id: root
implicitHeight: (title.height + contactsList.height) implicitHeight: (title.height + contactsList.height)
property ContactsStore contactsStore
property var contactsModel property var contactsModel
property int panelUsage: Constants.contactsPanelUsage.unknownPosition property int panelUsage: Constants.contactsPanelUsage.unknownPosition
@ -104,17 +101,18 @@ Item {
id: panelDelegate id: panelDelegate
width: ListView.view.width width: ListView.view.width
contactsStore: root.contactsStore
name: model.preferredDisplayName name: model.preferredDisplayName
ensVerified: model.isEnsVerified
publicKey: model.pubKey publicKey: model.pubKey
compressedPk: Utils.getCompressedPk(model.pubKey)
iconSource: model.icon iconSource: model.icon
isContact: model.isContact isContact: model.isContact
isBlocked: model.isBlocked isBlocked: model.isBlocked
isVerified: model.isVerified isVerified: model.isVerified
isUntrustworthy: model.isUntrustworthy isUntrustworthy: model.isUntrustworthy
subTitle: model.ensVerified ? "" : Utils.getElidedCompressedPk(model.pubKey)
pubKeyColor: Utils.colorForPubkey(model.pubKey)
colorHash: Utils.getColorHashAsJson(model.pubKey, model.ensVerified)
showSendMessageButton: isContact && !isBlocked showSendMessageButton: isContact && !isBlocked
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContactContextMenu(publicKey, name, icon) root.openContactContextMenu(publicKey, name, icon)

View File

@ -1,3 +1,4 @@
ContactPanel 1.0 ContactPanel.qml
ProfileDescriptionPanel 1.0 ProfileDescriptionPanel.qml ProfileDescriptionPanel 1.0 ProfileDescriptionPanel.qml
ProfileShowcaseAccountsPanel 1.0 ProfileShowcaseAccountsPanel.qml ProfileShowcaseAccountsPanel 1.0 ProfileShowcaseAccountsPanel.qml
ProfileShowcaseAssetsPanel 1.0 ProfileShowcaseAssetsPanel.qml ProfileShowcaseAssetsPanel 1.0 ProfileShowcaseAssetsPanel.qml

View File

@ -172,7 +172,6 @@ SettingsContentBase {
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
} }
contactsStore: root.contactsStore
panelUsage: Constants.contactsPanelUsage.verifiedMutualContacts panelUsage: Constants.contactsPanelUsage.verifiedMutualContacts
onSendMessageActionTriggered: { onSendMessageActionTriggered: {
root.contactsStore.joinPrivateChat(publicKey) root.contactsStore.joinPrivateChat(publicKey)
@ -186,7 +185,6 @@ SettingsContentBase {
title: qsTr("Contacts") title: qsTr("Contacts")
contactsModel: root.contactsStore.myContactsModel contactsModel: root.contactsStore.myContactsModel
searchString: searchBox.text searchString: searchBox.text
contactsStore: root.contactsStore
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
} }
@ -227,7 +225,6 @@ SettingsContentBase {
Layout.fillWidth: true Layout.fillWidth: true
title: qsTr("Received") title: qsTr("Received")
searchString: searchBox.text searchString: searchBox.text
contactsStore: root.contactsStore
visible: count > 0 visible: count > 0
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
@ -254,7 +251,6 @@ SettingsContentBase {
Layout.fillWidth: true Layout.fillWidth: true
title: qsTr("Sent") title: qsTr("Sent")
searchString: searchBox.text searchString: searchBox.text
contactsStore: root.contactsStore
visible: count > 0 visible: count > 0
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
@ -279,7 +275,6 @@ SettingsContentBase {
// clip: true // clip: true
// title: qsTr("Received") // title: qsTr("Received")
// searchString: searchBox.text // searchString: searchBox.text
// contactsStore: root.contactsStore
// onOpenContactContextMenu: function (publicKey, name, icon) { // onOpenContactContextMenu: function (publicKey, name, icon) {
// root.openContextMenu(publicKey, name, icon) // root.openContextMenu(publicKey, name, icon)
// } // }
@ -297,7 +292,6 @@ SettingsContentBase {
// clip: true // clip: true
// title: qsTr("Sent") // title: qsTr("Sent")
// searchString: searchBox.text // searchString: searchBox.text
// contactsStore: root.contactsStore
// onOpenContactContextMenu: function (publicKey, name, icon) { // onOpenContactContextMenu: function (publicKey, name, icon) {
// root.openContextMenu(publicKey, name, icon) // root.openContextMenu(publicKey, name, icon)
// } // }
@ -316,7 +310,6 @@ SettingsContentBase {
ContactsListPanel { ContactsListPanel {
Layout.fillWidth: true Layout.fillWidth: true
searchString: searchBox.text searchString: searchBox.text
contactsStore: root.contactsStore
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
} }