ui/qml/widgets/ContactRow.qml

125 lines
2.6 KiB
QML
Raw Permalink Normal View History

2018-10-23 18:52:13 +00:00
import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.3
import CustomQmlTypes 1.0
RowLayout { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
anchors.left: parent.left
anchors.right: parent.right
visible: !deleted
2018-10-23 18:52:13 +00:00
2018-11-22 00:01:17 +00:00
property alias displayName: cn.text
2018-10-25 00:13:03 +00:00
property alias image: imgProfile.source
2018-11-22 00:01:17 +00:00
property string handle
property int badge
2018-10-23 18:52:13 +00:00
property bool isActive
property bool isHover
2018-11-22 00:01:17 +00:00
property bool trusted
property bool deleted
2018-10-25 00:13:03 +00:00
property alias status: imgProfile.status
2018-10-28 02:49:14 +00:00
property string server
2019-03-06 19:38:08 +00:00
property bool background: true
2018-10-23 18:52:13 +00:00
Rectangle { // CONTACT ENTRY BACKGROUND COLOR
id: root
anchors.left: parent.left
anchors.right: parent.right
2018-10-25 00:13:03 +00:00
height: childrenRect.height + 3
2018-10-23 18:52:13 +00:00
width: parent.width
2019-03-06 19:38:08 +00:00
color: background ? (isHover ? "#D2D2F3" : (isActive ? "#D2D2F3" : "#D2C0DD")) : windowItem.cwtch_background_color
2018-10-23 18:52:13 +00:00
RowLayout {
width: parent.width
anchors.left: parent.left
anchors.right: parent.right
2018-10-25 00:13:03 +00:00
ContactPicture {
2018-10-23 18:52:13 +00:00
id: imgProfile
showStatus: true
2018-10-23 18:52:13 +00:00
}
Label { // CONTACT NAME
id: cn
leftPadding: 10
rightPadding: 10
2018-10-28 02:49:14 +00:00
//wrapMode: Text.WordWrap
2018-10-23 18:52:13 +00:00
anchors.left: imgProfile.right
2018-10-28 02:49:14 +00:00
anchors.right: rectUnread.left
2018-10-23 18:52:13 +00:00
font.pixelSize: 16
2018-11-22 00:01:17 +00:00
font.italic: !trusted
2018-10-25 00:13:03 +00:00
textFormat: Text.PlainText
2018-10-28 02:49:14 +00:00
//fontSizeMode: Text.HorizontalFit
elide: Text.ElideRight
color: "#000000"
2018-10-23 18:52:13 +00:00
}
Rectangle { // UNREAD MESSAGES?
2018-10-28 02:49:14 +00:00
id: rectUnread
2018-10-23 18:52:13 +00:00
anchors.right: parent.right
height: 16
2018-10-29 18:00:21 +00:00
width: lblUnread.width + 10
2018-10-23 18:52:13 +00:00
radius: 8
color: "#4B3557"
2018-11-22 00:01:17 +00:00
visible: badge != 0
2018-10-28 02:49:14 +00:00
anchors.rightMargin: 9
2018-10-23 18:52:13 +00:00
Label {
2018-10-29 18:00:21 +00:00
id: lblUnread
2018-10-23 18:52:13 +00:00
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
color: "#FFFFFF"
font.pixelSize: 12
text: badge
}
}
}
}
MouseArea { // ONCLICK: LOAD CONVERSATION WITH THIS CONTACT
anchors.fill: parent
hoverEnabled: true
onClicked: {
gcd.broadcast("ResetMessagePane")
isActive = true
2018-10-29 18:00:21 +00:00
theStack.pane = theStack.messagePane
2018-11-22 00:01:17 +00:00
gcd.loadMessagesPane(handle)
if (handle.length == 32) {
gcd.requestGroupSettings(handle)
}
2018-10-23 18:52:13 +00:00
}
onEntered: {
isHover = true
}
onExited: {
isHover = false
}
}
Connections { // UPDATE UNREAD MESSAGES COUNTER
target: gcd
onResetMessagePane: function() {
isActive = false
}
2018-11-22 00:01:17 +00:00
onUpdateContact: function(_handle, _displayName, _image, _server, _badge, _status, _trusted) {
if (handle == _handle) {
displayName = _displayName
image = _image
server = _server
badge = _badge
status = _status
trusted = _trusted
2018-10-23 18:52:13 +00:00
}
}
}
}