status-desktop/ui/app/AppLayouts/Profile/panels/ContactPanel.qml

158 lines
5.6 KiB
QML
Raw Normal View History

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