2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-06 09:16:39 +00:00
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../shared/status"
|
2020-06-13 13:49:20 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
property string name: "Jotaro Kujo"
|
|
|
|
property string address: "0x04d8c07dd137bd1b73a6f51df148b4f77ddaa11209d36e43d8344c0a7d6db1cad6085f27cfb75dd3ae21d86ceffebe4cf8a35b9ce8d26baa19dc264efe6d8f221b"
|
|
|
|
property string identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="
|
2020-09-16 19:52:48 +00:00
|
|
|
property string localNickname: "JoJo"
|
2020-06-17 21:54:03 +00:00
|
|
|
property var profileClick: function() {}
|
2020-06-22 12:16:44 +00:00
|
|
|
property bool isContact: true
|
2020-07-24 11:27:26 +00:00
|
|
|
property bool isBlocked: false
|
|
|
|
property string searchStr: ""
|
2021-10-06 09:16:39 +00:00
|
|
|
signal clicked()
|
|
|
|
signal sendMessageActionTriggered()
|
|
|
|
signal unblockContactActionTriggered()
|
2020-08-10 11:56:16 +00:00
|
|
|
signal blockContactActionTriggered(name: string, address: string)
|
2020-08-10 12:15:57 +00:00
|
|
|
signal removeContactActionTriggered(address: string)
|
2021-01-21 16:46:00 +00:00
|
|
|
property bool isHovered: false
|
2020-07-24 11:27:26 +00:00
|
|
|
id: container
|
2020-06-13 13:49:20 +00:00
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
visible: isContact && (searchStr == "" || name.includes(searchStr))
|
2020-06-22 12:16:44 +00:00
|
|
|
height: visible ? 64 : 0
|
2020-06-13 13:49:20 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
2021-01-21 16:46:00 +00:00
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
2020-06-13 13:49:20 +00:00
|
|
|
border.width: 0
|
2020-07-02 15:14:31 +00:00
|
|
|
radius: Style.current.radius
|
2021-01-21 16:46:00 +00:00
|
|
|
color: isHovered ? Style.current.backgroundHover : Style.current.transparent
|
2020-06-13 13:49:20 +00:00
|
|
|
|
2020-09-22 14:45:09 +00:00
|
|
|
StatusImageIdenticon {
|
2020-06-13 13:49:20 +00:00
|
|
|
id: accountImage
|
|
|
|
anchors.left: parent.left
|
2021-01-21 16:46:00 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-06-13 13:49:20 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
source: identicon
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-13 13:49:20 +00:00
|
|
|
id: usernameText
|
|
|
|
text: name
|
|
|
|
elide: Text.ElideRight
|
|
|
|
anchors.right: parent.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
2020-06-13 13:49:20 +00:00
|
|
|
font.pixelSize: 17
|
|
|
|
anchors.top: accountImage.top
|
2020-07-24 11:27:26 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2020-06-13 13:49:20 +00:00
|
|
|
anchors.left: accountImage.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-06-13 13:49:20 +00:00
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
|
2021-01-21 16:46:00 +00:00
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: container.isHovered = true
|
|
|
|
onExited: container.isHovered = false
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onClicked: {
|
|
|
|
if (mouse.button === Qt.RightButton) {
|
|
|
|
contactContextMenu.popup()
|
|
|
|
return
|
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
container.clicked();
|
2021-01-21 16:46:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-17 09:22:35 +00:00
|
|
|
StatusContextMenuButton {
|
2020-07-24 11:27:26 +00:00
|
|
|
property int iconSize: 14
|
|
|
|
id: menuButton
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
2021-01-21 16:46:00 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
2020-07-24 11:27:26 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onExited: {
|
2021-01-21 16:46:00 +00:00
|
|
|
container.isHovered = false
|
2021-03-17 09:22:35 +00:00
|
|
|
menuButton.highlighted = false
|
2020-07-24 11:27:26 +00:00
|
|
|
}
|
|
|
|
onEntered: {
|
2021-01-21 16:46:00 +00:00
|
|
|
container.isHovered = true
|
2021-03-17 09:22:35 +00:00
|
|
|
menuButton.highlighted = true
|
2020-07-24 11:27:26 +00:00
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
contactContextMenu.popup()
|
|
|
|
}
|
|
|
|
|
|
|
|
PopupMenu {
|
|
|
|
id: contactContextMenu
|
|
|
|
hasArrow: false
|
|
|
|
Action {
|
2021-09-28 15:04:06 +00:00
|
|
|
icon.source: Style.svg("profileActive")
|
2020-07-24 11:27:26 +00:00
|
|
|
icon.width: menuButton.iconSize
|
|
|
|
icon.height: menuButton.iconSize
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "View Profile"
|
2020-07-24 11:27:26 +00:00
|
|
|
text: qsTrId("view-profile")
|
2020-10-02 13:02:56 +00:00
|
|
|
onTriggered: profileClick(true, name, address, identicon, "", localNickname)
|
2020-07-24 11:27:26 +00:00
|
|
|
enabled: true
|
|
|
|
}
|
|
|
|
Action {
|
2021-09-28 15:04:06 +00:00
|
|
|
icon.source: Style.svg("message")
|
2020-07-24 11:27:26 +00:00
|
|
|
icon.width: menuButton.iconSize
|
|
|
|
icon.height: menuButton.iconSize
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Send message"
|
2020-07-24 11:27:26 +00:00
|
|
|
text: qsTrId("send-message")
|
2021-10-06 09:16:39 +00:00
|
|
|
onTriggered: container.sendMessageActionTriggered()
|
2020-07-24 11:27:26 +00:00
|
|
|
enabled: !container.isBlocked
|
|
|
|
}
|
|
|
|
Action {
|
2021-09-28 15:04:06 +00:00
|
|
|
icon.source: Style.svg("block-icon")
|
2020-07-24 11:27:26 +00:00
|
|
|
icon.width: menuButton.iconSize
|
|
|
|
icon.height: menuButton.iconSize
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Block User"
|
2020-07-24 11:27:26 +00:00
|
|
|
text: qsTrId("block-user")
|
|
|
|
enabled: !container.isBlocked
|
|
|
|
onTriggered: {
|
2020-08-10 11:56:16 +00:00
|
|
|
container.blockContactActionTriggered(name, address)
|
2020-07-24 11:27:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Action {
|
2021-09-28 15:04:06 +00:00
|
|
|
icon.source: Style.svg("remove-contact")
|
2020-07-24 11:27:26 +00:00
|
|
|
icon.width: menuButton.iconSize
|
|
|
|
icon.height: menuButton.iconSize
|
|
|
|
icon.color: Style.current.red
|
|
|
|
text: qsTrId("remove-contact")
|
|
|
|
enabled: container.isContact
|
2020-08-10 12:15:57 +00:00
|
|
|
onTriggered: {
|
|
|
|
container.removeContactActionTriggered(address)
|
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
}
|
|
|
|
Action {
|
2021-09-28 15:04:06 +00:00
|
|
|
icon.source: Style.svg("block-icon")
|
2020-07-24 11:27:26 +00:00
|
|
|
icon.width: menuButton.iconSize
|
|
|
|
icon.height: menuButton.iconSize
|
|
|
|
icon.color: Style.current.red
|
2020-09-14 12:12:47 +00:00
|
|
|
//% "Unblock User"
|
|
|
|
text: qsTrId("unblock-user")
|
2020-07-24 11:27:26 +00:00
|
|
|
enabled: container.isBlocked
|
|
|
|
onTriggered: {
|
2021-10-06 09:16:39 +00:00
|
|
|
container.unblockContactActionTriggered()
|
2020-07-24 11:27:26 +00:00
|
|
|
contactContextMenu.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-13 13:49:20 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
|