147 lines
2.9 KiB
QML
147 lines
2.9 KiB
QML
|
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
|
||
|
|
||
|
property alias nick: cn.text
|
||
|
property alias image: img.source
|
||
|
property string onion
|
||
|
property string badge
|
||
|
property bool isActive
|
||
|
property bool isHover
|
||
|
property bool isTrusted
|
||
|
property int status
|
||
|
|
||
|
|
||
|
Rectangle { // CONTACT ENTRY BACKGROUND COLOR
|
||
|
id: root
|
||
|
anchors.left: parent.left
|
||
|
anchors.right: parent.right
|
||
|
height: childrenRect.height
|
||
|
width: parent.width
|
||
|
color: isHover ? "#EEEEFF" : (isActive ? "#EEEEFF" : "#FFEEEE")
|
||
|
|
||
|
|
||
|
RowLayout {
|
||
|
width: parent.width
|
||
|
anchors.left: parent.left
|
||
|
anchors.right: parent.right
|
||
|
|
||
|
|
||
|
Item { // PROFILE IMAGE
|
||
|
id: imgProfile
|
||
|
implicitWidth: 48
|
||
|
implicitHeight: 48
|
||
|
anchors.left: parent.left
|
||
|
|
||
|
|
||
|
Image {
|
||
|
id: img
|
||
|
anchors.fill: parent
|
||
|
fillMode: Image.PreserveAspectFit
|
||
|
}
|
||
|
|
||
|
Rectangle { // PRESENCE INDICATOR
|
||
|
color: "#FFFFFF"
|
||
|
width: 8
|
||
|
height: 8
|
||
|
radius: 2
|
||
|
anchors.right: parent.right
|
||
|
anchors.bottom: parent.bottom
|
||
|
anchors.margins: 4
|
||
|
|
||
|
|
||
|
Rectangle { //-2:WtfCodeError,-1:Untrusted,0:Disconnected,1:Connecting,2:Connected,3:Authenticated,4:Failed,5:Killed
|
||
|
color: status==3?"green":(status==4?"red":(status==-1?"blue":"orange"))
|
||
|
width: 5
|
||
|
height: 5
|
||
|
radius: 2
|
||
|
anchors.right: parent.right
|
||
|
anchors.bottom: parent.bottom
|
||
|
anchors.margins: 1.5
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Label { // CONTACT NAME
|
||
|
id: cn
|
||
|
leftPadding: 10
|
||
|
rightPadding: 10
|
||
|
wrapMode: Text.WordWrap
|
||
|
anchors.left: imgProfile.right
|
||
|
font.pixelSize: 16
|
||
|
font.italic: !isTrusted
|
||
|
}
|
||
|
|
||
|
Rectangle { // UNREAD MESSAGES?
|
||
|
anchors.right: parent.right
|
||
|
height: 16
|
||
|
width: childrenRect.width + 10
|
||
|
radius: 8
|
||
|
color: "#4B3557"
|
||
|
visible: badge != "0"
|
||
|
anchors.rightMargin: 3
|
||
|
|
||
|
|
||
|
Label {
|
||
|
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
|
||
|
gcd.loadMessagesPane(onion)
|
||
|
}
|
||
|
|
||
|
onEntered: {
|
||
|
isHover = true
|
||
|
}
|
||
|
|
||
|
onExited: {
|
||
|
isHover = false
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Connections { // UPDATE UNREAD MESSAGES COUNTER
|
||
|
target: gcd
|
||
|
|
||
|
onSetUnread: function(foronion, n) {
|
||
|
if (onion == foronion) {
|
||
|
badge = ""+n
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onResetMessagePane: function() {
|
||
|
isActive = false
|
||
|
}
|
||
|
|
||
|
onSetConnectionStatus: function(foronion, x) {
|
||
|
if (onion == foronion) {
|
||
|
status = x
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onMarkTrusted: function(foronion) {
|
||
|
if (onion == foronion) {
|
||
|
isTrusted = true
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|