You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.9 KiB

import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.0
Rectangle {
id: appWindow
visible: true
color: "black"
property int itemHeight: 68;
property string avatarBorderColor: "#999999"
property string chatBorderColor: "#30302f"
property string nickColor: "#86d5fc"
ListView {
id: chatListView
property int nickWidth: 0
anchors.fill: parent
anchors.topMargin: 10
anchors.leftMargin: 20
anchors.rightMargin: 20
model: chatModel
onCountChanged: { // scroll to bottom
chatListView.currentIndex = count - 1
}
delegate: Rectangle {
height: {
var dynamic_height = textChatMessage.implicitHeight + 4;
if(dynamic_height > itemHeight) return dynamic_height;
return itemHeight;
}
width: parent.width
color: "black"
RowLayout {
spacing: 0
width: parent.width
Rectangle {
Layout.alignment: Qt.AlignVCenter
color: avatarBorderColor
Layout.preferredWidth: itemHeight
Layout.minimumHeight: itemHeight
Image {
width: itemHeight - 2
height: itemHeight - 2
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
id: imgStatus
source: {
if(name == "_self") return "qrc:///avatar.jpg"
else if(name == "Wizzup") return "qrc:///wajer.png"
return "qrc:///wabbit.png"
}
smooth: true
visible: true
}
}
Item {
// spacer
Layout.preferredWidth: 10
Layout.minimumHeight: itemHeight
}
RowLayout {
Layout.fillWidth: true
Text {
id: textNick
Layout.alignment: Qt.AlignVCenter
Layout.minimumWidth: chatListView.nickWidth
textFormat: Text.PlainText
text: {
if(name == "_self") return "d4irc";
return name
}
color: nickColor
font.pointSize: 18
Component.onCompleted: {
if(implicitWidth > chatListView.nickWidth)
chatListView.nickWidth = implicitWidth
}
}
Text {
id: textChatMessage
Layout.fillWidth: true
Layout.leftMargin: 8
Layout.alignment: Qt.AlignVCenter
textFormat: Text.PlainText
text: message
color: "white"
wrapMode: Text.WordWrap
font.pointSize: 14
font.bold: name == "dsc" ? true : false;
}
Item {
Layout.minimumHeight: itemHeight
Layout.fillWidth: true
}
Text {
Layout.leftMargin: 12
Layout.alignment: Qt.AlignVCenter
textFormat: Text.PlainText
text: hourstr
color: "grey"
font.pointSize: 12
}
}
}
}
}
}