This repository has been archived on 2021-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
ui/qml/widgets/ContactRow.qml

127 lines
3.3 KiB
QML
Raw 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
2019-04-16 19:40:19 +00:00
Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
2018-10-23 18:52:13 +00:00
anchors.left: parent.left
anchors.right: parent.right
visible: !deleted
2019-04-17 21:03:50 +00:00
height: 48 * logscale + 3
2019-04-16 19:40:19 +00:00
implicitHeight: height
2018-10-23 18:52:13 +00:00
2019-04-17 21:03:50 +00:00
property real logscale: 4 * Math.log10(gcd.themeScale + 1)
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
2019-04-16 19:40:19 +00:00
id: crRect
2018-10-23 18:52:13 +00:00
anchors.left: parent.left
anchors.right: parent.right
2019-04-17 21:03:50 +00:00
height: 48 * logscale + 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
2019-04-16 19:40:19 +00:00
ContactPicture {
id: imgProfile
showStatus: true
}
Label { // CONTACT NAME
id: cn
leftPadding: 10
rightPadding: 10
//wrapMode: Text.WordWrap
anchors.left: imgProfile.right
anchors.right: rectUnread.left
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 16 * gcd.themeScale
font.italic: !trusted
textFormat: Text.PlainText
//fontSizeMode: Text.HorizontalFit
elide: Text.ElideRight
color: "#000000"
}
Rectangle { // UNREAD MESSAGES?
id: rectUnread
height: txtmetric.tightBoundingRect.height + 8 * gcd.themeScale
width: txtmetric.tightBoundingRect.width + 8 * gcd.themeScale
radius: 8 * gcd.themeScale
color: "#4B3557"
visible: badge != 0
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 9 * gcd.themeScale
Label {
id: lblUnread
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
color: "#FFFFFF"
font.pixelSize: 12 * gcd.themeScale
text: txtmetric.text
}
TextMetrics {
id: txtmetric
text: badge
font: lblUnread.font
}
}
2018-10-23 18:52:13 +00:00
}
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
}
}
}
}