2021-07-06 17:58:19 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2022-05-20 12:53:40 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.status 1.0
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2022-02-23 17:08:01 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
import "../controls"
|
|
|
|
|
2022-02-23 17:08:01 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-07-06 17:58:19 +00:00
|
|
|
|
2021-07-22 14:53:19 +00:00
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
anchors.fill: parent
|
2021-11-30 14:49:45 +00:00
|
|
|
|
|
|
|
// Important:
|
2021-12-09 12:53:40 +00:00
|
|
|
// Each chat/channel has its own ChatContentModule and each ChatContentModule has a single usersModule
|
2021-11-30 14:49:45 +00:00
|
|
|
// usersModule on the backend contains everything needed for this component
|
|
|
|
property var usersModule
|
2021-09-01 17:38:39 +00:00
|
|
|
property var messageContextMenu
|
2022-02-23 17:08:01 +00:00
|
|
|
property string label
|
2021-07-06 17:58:19 +00:00
|
|
|
|
2022-03-09 10:27:32 +00:00
|
|
|
property var rootStore
|
|
|
|
|
2022-02-23 17:08:01 +00:00
|
|
|
StatusBaseText {
|
2021-07-22 14:53:19 +00:00
|
|
|
id: titleText
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
2021-08-26 12:04:47 +00:00
|
|
|
opacity: (root.width > 58) ? 1.0 : 0.0
|
2021-07-22 14:53:19 +00:00
|
|
|
visible: (opacity > 0.1)
|
|
|
|
font.pixelSize: Style.current.primaryTextFontSize
|
2022-02-23 17:08:01 +00:00
|
|
|
font.weight: Font.Medium
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
text: root.label
|
2021-07-22 14:53:19 +00:00
|
|
|
}
|
2021-07-06 22:41:26 +00:00
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: userListView
|
2021-07-27 08:51:32 +00:00
|
|
|
clip: true
|
2021-09-21 13:13:17 +00:00
|
|
|
ScrollBar.vertical: ScrollBar {
|
|
|
|
policy: ScrollBar.AsNeeded
|
|
|
|
}
|
2021-07-22 14:53:19 +00:00
|
|
|
anchors {
|
|
|
|
top: titleText.bottom
|
|
|
|
topMargin: Style.current.padding
|
2021-11-30 12:27:08 +00:00
|
|
|
left: parent.left
|
2021-07-22 14:53:19 +00:00
|
|
|
right: parent.right
|
|
|
|
bottom: parent.bottom
|
|
|
|
bottomMargin: Style.current.bigPadding
|
|
|
|
}
|
2021-07-06 22:41:26 +00:00
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
2021-11-30 14:49:45 +00:00
|
|
|
model: usersModule.model
|
2022-02-23 17:08:01 +00:00
|
|
|
section.property: "onlineStatus"
|
|
|
|
section.delegate: (root.width > 58) ? sectionDelegateComponent : null
|
2022-05-20 12:53:40 +00:00
|
|
|
delegate: StatusMemberListItem {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 8
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
nickName: model.localNickname
|
2022-06-03 13:24:49 +00:00
|
|
|
userName: model.displayName
|
2022-06-10 10:34:46 +00:00
|
|
|
pubKey: Utils.getCompressedPk(model.pubKey)
|
2022-06-03 13:24:49 +00:00
|
|
|
isContact: model.isContact
|
|
|
|
isVerified: model.isVerified
|
|
|
|
isUntrustworthy: model.isUntrustworthy
|
2022-05-30 10:00:53 +00:00
|
|
|
isAdmin: model.isAdmin
|
2022-05-20 12:53:40 +00:00
|
|
|
image.source: {
|
2022-06-03 13:24:49 +00:00
|
|
|
if ((!model.isContact &&
|
2022-05-20 12:53:40 +00:00
|
|
|
Global.privacyModuleInst.profilePicturesVisibility !==
|
|
|
|
Constants.profilePicturesVisibility.everyone)) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return model.icon;
|
|
|
|
}
|
2022-06-03 13:24:49 +00:00
|
|
|
image.isIdenticon: false
|
2022-05-20 12:53:40 +00:00
|
|
|
|
2022-06-03 13:24:49 +00:00
|
|
|
status: model.onlineStatus
|
|
|
|
icon.color: Theme.palette.userCustomizationColors[Utils.colorIdForPubkey(model.pubKey)] // FIXME: use model.colorId
|
|
|
|
ringSettings.ringSpecModel: Utils.getColorHashAsJson(model.pubKey) // FIXME: use model.colorHash
|
2022-05-20 12:53:40 +00:00
|
|
|
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
|
2022-06-03 13:24:49 +00:00
|
|
|
messageContextMenu.selectedUserPublicKey = model.pubKey
|
|
|
|
messageContextMenu.selectedUserDisplayName = model.displayName
|
2022-05-20 12:53:40 +00:00
|
|
|
messageContextMenu.selectedUserIcon = image.source
|
|
|
|
messageContextMenu.popup()
|
|
|
|
} else if (mouse.button === Qt.LeftButton && !!messageContextMenu) {
|
2022-06-03 13:24:49 +00:00
|
|
|
Global.openProfilePopup(model.pubKey);
|
2022-05-20 12:53:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-23 17:08:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: sectionDelegateComponent
|
|
|
|
Item {
|
|
|
|
width: parent.width
|
|
|
|
height: 24
|
|
|
|
StyledText {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
font.pixelSize: Style.current.additionalTextSize
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
text: {
|
|
|
|
switch(parseInt(section)) {
|
|
|
|
case Constants.userStatus.offline: return qsTr("Offline")
|
|
|
|
case Constants.userStatus.online: return qsTr("Online")
|
|
|
|
case Constants.userStatus.doNotDisturb: return qsTr("Do not disturb")
|
|
|
|
case Constants.userStatus.idle: return qsTr("Idle")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-06 22:41:26 +00:00
|
|
|
}
|
2021-07-22 14:53:19 +00:00
|
|
|
}
|