2021-06-30 18:46:26 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import "../../../../shared"
|
2021-10-14 13:09:35 +00:00
|
|
|
import "../../../../shared/panels"
|
2021-06-30 18:46:26 +00:00
|
|
|
import "../../../../shared/status"
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-06-30 18:46:26 +00:00
|
|
|
import "../components"
|
|
|
|
|
2021-09-23 10:07:07 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
2021-06-30 18:46:26 +00:00
|
|
|
Item {
|
2021-08-27 12:48:53 +00:00
|
|
|
id: wrapper
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: applicationWindow.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
height: rectangle.height + 4
|
|
|
|
|
2021-06-30 18:46:26 +00:00
|
|
|
property string publicKey: ""
|
|
|
|
property string name: "channelName"
|
|
|
|
property string lastSeen: ""
|
|
|
|
property string identicon
|
2021-08-27 12:48:53 +00:00
|
|
|
property int statusType: -1
|
2021-06-30 18:46:26 +00:00
|
|
|
property bool hovered: false
|
|
|
|
property bool enableMouseArea: true
|
2021-08-27 12:48:53 +00:00
|
|
|
property bool isOnline: chatsModel.isOnline
|
2021-06-30 18:46:26 +00:00
|
|
|
property var currentTime
|
|
|
|
property color color: {
|
|
|
|
if (wrapper.hovered) {
|
|
|
|
return Style.current.menuBackgroundHover
|
|
|
|
}
|
|
|
|
return Style.current.transparent
|
|
|
|
}
|
|
|
|
property string profileImage: appMain.getProfileImage(publicKey) || ""
|
|
|
|
property bool isCurrentUser: publicKey === profileModel.profile.pubKey
|
|
|
|
|
|
|
|
Rectangle {
|
2021-08-27 12:48:53 +00:00
|
|
|
id: rectangle
|
|
|
|
width: parent.width
|
|
|
|
height: 40
|
|
|
|
radius: 8
|
|
|
|
color: wrapper.color
|
2021-06-30 18:46:26 +00:00
|
|
|
Connections {
|
|
|
|
target: profileModel.contacts.list
|
|
|
|
onContactChanged: {
|
|
|
|
if (pubkey === wrapper.publicKey) {
|
|
|
|
wrapper.profileImage = appMain.getProfileImage(wrapper.publicKey)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIdenticon {
|
|
|
|
id: contactImage
|
|
|
|
height: 28
|
|
|
|
width: 28
|
|
|
|
chatId: wrapper.publicKey
|
|
|
|
chatName: wrapper.name
|
|
|
|
chatType: Constants.chatTypeOneToOne
|
|
|
|
identicon: wrapper.profileImage || wrapper.identicon
|
|
|
|
anchors.left: parent.left
|
2021-08-18 09:33:49 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2021-06-30 18:46:26 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: contactInfo
|
|
|
|
text: Emoji.parse(Utils.removeStatusEns(Utils.filterXSS(wrapper.name))) + (isCurrentUser ? " " + qsTrId("(you)") : "")
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-09-23 10:07:07 +00:00
|
|
|
StatusBadge {
|
|
|
|
id: statusBadge
|
|
|
|
width: 15
|
|
|
|
height: 15
|
2021-06-30 18:46:26 +00:00
|
|
|
anchors.left: contactImage.right
|
2021-07-06 18:00:55 +00:00
|
|
|
anchors.leftMargin: -Style.current.smallPadding
|
2021-06-30 18:46:26 +00:00
|
|
|
anchors.bottom: contactImage.bottom
|
2021-09-23 10:07:07 +00:00
|
|
|
visible: wrapper.isOnline && !((statusType === -1) && (lastSeenMinutesAgo > 7))
|
|
|
|
border.width: 3
|
|
|
|
border.color: Theme.palette.statusAppNavBar.backgroundColor
|
|
|
|
property real lastSeenMinutesAgo: ((currentTime/1000 - parseInt(lastSeen)) / 60);
|
2021-06-30 18:46:26 +00:00
|
|
|
color: {
|
2021-08-27 12:48:53 +00:00
|
|
|
if (visible) {
|
|
|
|
if (statusType === Constants.statusType_DoNotDisturb) {
|
|
|
|
return Style.current.red;
|
|
|
|
} else if (isCurrentUser || (lastSeenMinutesAgo < 5.5)) {
|
|
|
|
return Style.current.green;
|
|
|
|
} else if (((statusType !== -1) && (lastSeenMinutesAgo > 5.5)) ||
|
|
|
|
((statusType === -1) && (lastSeenMinutesAgo < 7))) {
|
|
|
|
return Style.current.orange;
|
|
|
|
} else if ((statusType === -1) && (lastSeenMinutesAgo > 7)) {
|
|
|
|
return "transparent";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return "transparent";
|
2021-06-30 18:46:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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: {
|
2021-08-06 15:44:57 +00:00
|
|
|
if (mouse.button === Qt.LeftButton) {
|
|
|
|
openProfilePopup(wrapper.name, wrapper.publicKey, (wrapper.profileImage || wrapper.identicon), "", appMain.getUserNickname(wrapper.publicKey));
|
|
|
|
}
|
|
|
|
else if (mouse.button === Qt.RightButton) {
|
2021-08-25 20:31:00 +00:00
|
|
|
// Set parent, X & Y positions for the messageContextMenu
|
|
|
|
messageContextMenu.parent = rectangle
|
|
|
|
messageContextMenu.setXPosition = function() { return 0}
|
|
|
|
messageContextMenu.setYPosition = function() { return rectangle.height}
|
2021-08-06 15:44:57 +00:00
|
|
|
messageContextMenu.isProfile = true;
|
|
|
|
messageContextMenu.show(wrapper.name, wrapper.publicKey, (wrapper.profileImage || wrapper.identicon), "", appMain.getUserNickname(wrapper.publicKey))
|
|
|
|
}
|
2021-06-30 18:46:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;formeditorColor:"#ffffff";height:64;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|