status-desktop/ui/app/AppLayouts/Chat/controls/Contact.qml

104 lines
3.0 KiB
QML
Raw Normal View History

2020-06-17 15:56:48 +00:00
import QtQuick 2.3
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import Qt.labs.platform 1.1
import utils 1.0
import StatusQ.Controls 0.1 as StatusQControls
import StatusQ.Components 0.1
import shared.panels 1.0
import shared.status 1.0
2020-06-17 15:56:48 +00:00
Rectangle {
property string pubKey: "0x123456"
property string name: "Jotaro Kujo"
property string identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="
property bool isIdenticon: true
2020-06-17 15:56:48 +00:00
2020-06-22 12:16:44 +00:00
property bool isContact: true
2020-06-17 15:56:48 +00:00
property bool isUser: false
property bool isVisible: true
property bool showCheckbox: true
property bool clickable: true
2020-06-17 15:56:48 +00:00
property bool isChecked: false
property bool isHovered: false
2020-06-17 15:56:48 +00:00
property var onItemChecked: (function(pubKey, itemChecked) { console.log(pubKey, itemChecked) })
property var onContactClicked
id: root
2020-06-22 12:16:44 +00:00
visible: isVisible && (isContact || isUser)
height: visible ? 64 : 0
2020-06-17 15:56:48 +00:00
anchors.right: parent.right
anchors.left: parent.left
border.width: 0
radius: Style.current.radius
color: isHovered ? Style.current.backgroundHover : Style.current.transparent
2020-06-17 15:56:48 +00:00
StatusSmartIdenticon {
2020-06-17 15:56:48 +00:00
id: accountImage
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: Style.current.padding
image.source: identicon
image.isIdenticon: isIdenticon
2020-06-17 15:56:48 +00:00
}
2022-02-09 09:43:23 +00:00
StyledText {
2020-06-17 15:56:48 +00:00
id: usernameText
text: name
elide: Text.ElideRight
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
2020-06-17 15:56:48 +00:00
font.pixelSize: 17
anchors.top: accountImage.top
anchors.topMargin: 10
anchors.left: accountImage.right
anchors.leftMargin: Style.current.padding
2020-06-17 15:56:48 +00:00
}
StatusQControls.StatusCheckBox {
2020-06-17 15:56:48 +00:00
id: assetCheck
visible: showCheckbox && !isUser
2020-06-17 15:56:48 +00:00
anchors.top: accountImage.top
anchors.topMargin: 6
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
2020-06-17 15:56:48 +00:00
checked: isChecked
onClicked: {
isChecked = !isChecked
onItemChecked(pubKey, isChecked)
}
}
StyledText {
2020-06-17 15:56:48 +00:00
visible: isUser
//% "Admin"
text: qsTrId("group-chat-admin")
2020-06-17 15:56:48 +00:00
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
2020-06-17 15:56:48 +00:00
font.pixelSize: 15
color: Style.current.darkGrey
2020-06-17 15:56:48 +00:00
anchors.top: accountImage.top
anchors.topMargin: 10
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
enabled: root.clickable || root.showCheckbox
hoverEnabled: root.clickable || root.showCheckbox
onEntered: root.isHovered = true
onExited: root.isHovered = false
onClicked: {
if (typeof root.onContactClicked !== "function") {
return assetCheck.clicked()
}
root.onContactClicked()
}
}
2020-06-17 15:56:48 +00:00
}