170 lines
4.4 KiB
QML
170 lines
4.4 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
|
|
import "../styles"
|
|
import QtQuick.Controls 1.4
|
|
import QtQuick.Controls.Styles 1.4
|
|
|
|
|
|
Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
height: 48 * logscale + 3
|
|
implicitHeight: height
|
|
|
|
property real logscale: 4 * Math.log10(gcd.themeScale + 1)
|
|
property alias displayName: cn.text
|
|
property alias image: imgProfile.source
|
|
property string handle
|
|
property int badge
|
|
property bool isActive
|
|
property bool isHover
|
|
property bool trusted
|
|
property bool blocked
|
|
property bool loading
|
|
property alias status: imgProfile.status
|
|
property string server
|
|
property bool background: true
|
|
|
|
|
|
Rectangle { // CONTACT ENTRY BACKGROUND COLOR
|
|
id: crRect
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
height: 48 * logscale + 3
|
|
width: parent.width
|
|
color: background ? (isHover ? "#D2D2F3" : (isActive ? "#D2D2F3" : "#D2C0DD")) : windowItem.cwtch_background_color
|
|
|
|
ContactPicture {
|
|
id: imgProfile
|
|
showStatus: true
|
|
}
|
|
|
|
Label { // CONTACT NAME
|
|
id: cn
|
|
leftPadding: 10
|
|
rightPadding: 10
|
|
//wrapMode: Text.WordWrap
|
|
anchors.left: imgProfile.right
|
|
anchors.right: loadingProgress.left
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
font.pixelSize: 16 * gcd.themeScale
|
|
font.italic: !trusted
|
|
font.strikeout: blocked
|
|
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
|
|
}
|
|
}
|
|
|
|
ProgressBar { // LOADING ?
|
|
id: loadingProgress
|
|
property bool running
|
|
running: loading
|
|
visible: loading
|
|
|
|
anchors.right: rectUnread.left
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.leftMargin: 1 * gcd.themeScale
|
|
anchors.rightMargin: 1 * gcd.themeScale
|
|
|
|
|
|
height: cn.height/2
|
|
width: 100 * gcd.themeScale
|
|
|
|
|
|
|
|
indeterminate: true
|
|
|
|
style: ProgressBarStyle {
|
|
progress: CwtchProgress { running: loadingProgress.running}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
MouseArea { // ONCLICK: LOAD CONVERSATION WITH THIS CONTACT
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
|
|
onClicked: {
|
|
gcd.broadcast("ResetMessagePane")
|
|
isActive = true
|
|
theStack.pane = theStack.messagePane
|
|
gcd.loadMessagesPane(handle)
|
|
if (handle.length == 32) {
|
|
gcd.requestGroupSettings(handle)
|
|
}
|
|
}
|
|
|
|
onEntered: {
|
|
isHover = true
|
|
}
|
|
|
|
onExited: {
|
|
isHover = false
|
|
}
|
|
}
|
|
|
|
Connections { // UPDATE UNREAD MESSAGES COUNTER
|
|
target: gcd
|
|
|
|
onResetMessagePane: function() {
|
|
isActive = false
|
|
}
|
|
|
|
onUpdateContact: function(_handle, _displayName, _image, _server, _badge, _status, _trusted, _blocked, _loading) {
|
|
if (handle == _handle) {
|
|
displayName = _displayName + (_blocked == true ? " (blocked)" : "")
|
|
image = _image
|
|
server = _server
|
|
badge = _badge
|
|
status = _status
|
|
trusted = _trusted
|
|
blocked = _blocked
|
|
loading = _loading
|
|
|
|
|
|
if (loading == true) {
|
|
loadingProgress.visible = true
|
|
loadingProgress.running = true
|
|
} else {
|
|
loadingProgress.visible = false
|
|
loadingProgress.running = false
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|