diff --git a/ui/app/AppLayouts/Chat/controls/UserDelegate.qml b/ui/app/AppLayouts/Chat/controls/UserDelegate.qml deleted file mode 100644 index 80aa7b5326..0000000000 --- a/ui/app/AppLayouts/Chat/controls/UserDelegate.qml +++ /dev/null @@ -1,132 +0,0 @@ -import QtQuick 2.14 -import QtQuick.Controls 2.14 - -import utils 1.0 - -import shared 1.0 -import shared.panels 1.0 -import shared.controls.chat 1.0 - -import StatusQ.Components 0.1 -import StatusQ.Core.Theme 0.1 -import StatusQ.Core 0.1 - -Item { - id: wrapper - anchors.right: parent.right - anchors.left: parent.left - height: rectangle.height + 4 - - property string publicKey: "" - property string name: "" - property string icon: "" - property bool isCurrentUser: false - property bool isAdded: false - property string iconToShow: { - if ((!isAdded && - Global.privacyModuleInst.profilePicturesVisibility !== - Constants.profilePicturesVisibility.everyone)) { - return "" - } - - return icon - } - property int userStatus: Constants.userStatus.offline - property var messageContextMenu - property bool enableMouseArea: true - property bool hovered: false - property color color: { - if (wrapper.hovered) { - return Style.current.menuBackgroundHover - } - return Style.current.transparent - } - - Rectangle { - id: rectangle - width: parent.width - height: 40 - radius: 8 - color: wrapper.color - - UserImage { - id: contactImage - anchors.left: parent.left - anchors.leftMargin: Style.current.padding - anchors.verticalCenter: parent.verticalCenter - - imageWidth: 28 - imageHeight: 28 - name: wrapper.name - pubkey: wrapper.publicKey - image: wrapper.iconToShow - } - - StyledText { - id: contactInfo - text: wrapper.name - anchors.right: parent.right - anchors.rightMargin: Style.current.smallPadding - elide: Text.ElideRight - color: Style.current.textColor - font.weight: Font.Medium - font.pixelSize: 15 - anchors.left: contactImage.right - anchors.leftMargin: Style.current.halfPadding - anchors.verticalCenter: parent.verticalCenter - } - - StatusBadge { - id: statusBadge - width: 15 - height: 15 - anchors.left: contactImage.right - anchors.leftMargin: -Style.current.smallPadding - anchors.bottom: contactImage.bottom - visible: wrapper.userStatus !== Constants.userStatus.offline - border.width: 3 - border.color: Theme.palette.statusAppNavBar.backgroundColor - color: { - if(wrapper.userStatus === Constants.userStatus.online) - return Style.current.green - else if(wrapper.userStatus === Constants.userStatus.idle) - return Style.current.orange - else if(wrapper.userStatus === Constants.userStatus.doNotDisturb) - return Style.current.red - - return "transparent" - } - } - - MouseArea { - enabled: enableMouseArea - cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor - acceptedButtons: Qt.LeftButton | Qt.RightButton - anchors.fill: parent - hoverEnabled: true - onEntered: { - wrapper.hovered = true - } - onExited: { - wrapper.hovered = false - } - onClicked: { - if (mouse.button === Qt.RightButton) { - // Set parent, X & Y positions for the messageContextMenu - messageContextMenu.parent = rectangle - messageContextMenu.setXPosition = function() { return 0} - messageContextMenu.setYPosition = function() { return rectangle.height} - - messageContextMenu.isProfile = true - messageContextMenu.myPublicKey = userProfile.pubKey - messageContextMenu.selectedUserPublicKey = wrapper.publicKey - messageContextMenu.selectedUserDisplayName = wrapper.name - messageContextMenu.selectedUserIcon = wrapper.iconToShow - messageContextMenu.popup() - } else if (mouse.button === Qt.LeftButton && !!messageContextMenu) { - Global.openProfilePopup(wrapper.publicKey); - } - } - } - } -} diff --git a/ui/app/AppLayouts/Chat/panels/UserListPanel.qml b/ui/app/AppLayouts/Chat/panels/UserListPanel.qml index e38311d14e..e9f3f231c1 100644 --- a/ui/app/AppLayouts/Chat/panels/UserListPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/UserListPanel.qml @@ -1,5 +1,6 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 +import StatusQ.Components 0.1 import shared 1.0 import shared.panels 1.0 import shared.status 1.0 @@ -54,17 +55,48 @@ Item { } boundsBehavior: Flickable.StopAtBounds model: usersModule.model - delegate: UserDelegate { - publicKey: model.id - name: model.name - icon: model.icon - isAdded: model.isAdded - userStatus: model.onlineStatus - messageContextMenu: root.messageContextMenu - isCurrentUser: rootStore.isCurrentUser(model.id) - } section.property: "onlineStatus" section.delegate: (root.width > 58) ? sectionDelegateComponent : null + delegate: StatusMemberListItem { + anchors.left: parent.left + anchors.leftMargin: 8 + anchors.right: parent.right + anchors.rightMargin: 8 + nickName: model.localNickname + userName: model.name + chatKey: model.id + trustIndicator: model.trustIndicator + isMutualContact: model.isMutualContact + image.source: { + if ((!model.isAdded && + Global.privacyModuleInst.profilePicturesVisibility !== + Constants.profilePicturesVisibility.everyone)) { + return ""; + } + return model.icon; + } + image.isIdenticon: model.isIdenticon + + isOnline: model.onlineStatus + icon.color: Theme.palette.userCustomizationColors[Utils.colorIdForPubkey(model.id)] + ringSettings.ringSpecModel: Utils.getColorHashAsJson(model.id) + onClicked: { + if (mouse.button === Qt.RightButton) { + // Set parent, X & Y positions for the messageContextMenu + messageContextMenu.parent = this + messageContextMenu.setXPosition = function() { return 0; } + messageContextMenu.setYPosition = function() { return mouse.y + (Style.current.halfPadding/2); } + messageContextMenu.isProfile = true + messageContextMenu.myPublicKey = userProfile.pubKey + messageContextMenu.selectedUserPublicKey = model.id + messageContextMenu.selectedUserDisplayName = model.name + messageContextMenu.selectedUserIcon = image.source + messageContextMenu.popup() + } else if (mouse.button === Qt.LeftButton && !!messageContextMenu) { + Global.openProfilePopup(model.id); + } + } + } } Component {