2019-03-22 14:28:14 +11:00
|
|
|
import QtQuick 2.7
|
|
|
|
import QtQuick.Controls 2.0
|
|
|
|
import QtQuick.Layouts 1.4
|
2019-03-26 20:52:43 +11:00
|
|
|
import "../base" as Base
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-03-26 18:19:55 +11:00
|
|
|
MouseArea {
|
2019-03-26 09:29:46 +11:00
|
|
|
id: "root"
|
2019-03-26 18:19:55 +11:00
|
|
|
width: roomList.width
|
2019-03-26 09:29:46 +11:00
|
|
|
height: Math.max(roomLabel.height + subtitleLabel.height, avatar.height)
|
2019-03-22 14:28:14 +11:00
|
|
|
|
2019-03-26 18:19:55 +11:00
|
|
|
onClicked: pageStack.show_room(
|
2019-04-12 18:33:09 +10:00
|
|
|
roomList.user_id,
|
2019-03-26 18:19:55 +11:00
|
|
|
roomList.model.get(index)
|
|
|
|
)
|
|
|
|
|
2019-03-22 14:28:14 +11:00
|
|
|
RowLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
id: row
|
|
|
|
spacing: 1
|
|
|
|
|
2019-03-28 10:21:14 +11:00
|
|
|
Base.Avatar { id: avatar; name: display_name; dimmension: 36 }
|
2019-03-22 14:28:14 +11:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
|
2019-03-26 20:52:43 +11:00
|
|
|
Base.HLabel {
|
2019-03-22 14:28:14 +11:00
|
|
|
id: roomLabel
|
|
|
|
text: display_name
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 1
|
|
|
|
Layout.maximumWidth: row.width - row.spacing - avatar.width
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
2019-03-26 09:29:46 +11:00
|
|
|
|
|
|
|
topPadding: -2
|
|
|
|
bottomPadding: subtitleLabel.visible ? 0 : topPadding
|
|
|
|
leftPadding: 5
|
|
|
|
rightPadding: leftPadding
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|
2019-03-26 20:52:43 +11:00
|
|
|
Base.HLabel {
|
2019-03-28 09:38:48 +11:00
|
|
|
function get_text() {
|
2019-04-12 18:33:09 +10:00
|
|
|
var msgs = Backend.models.messages[room_id]
|
2019-03-28 09:38:48 +11:00
|
|
|
if (msgs.count < 1) { return "" }
|
|
|
|
|
|
|
|
var msg = msgs.get(-1)
|
2019-04-12 18:33:09 +10:00
|
|
|
var color_ = (msg.sender_id === roomList.user_id ?
|
2019-03-28 09:38:48 +11:00
|
|
|
"darkblue" : "purple")
|
2019-04-12 18:33:09 +10:00
|
|
|
var client = Backend.clientManager.clients[RoomList.for_user_id]
|
2019-03-28 09:38:48 +11:00
|
|
|
|
|
|
|
return "<font color=\"" + color_ + "\">" +
|
2019-04-12 18:33:09 +10:00
|
|
|
client.getUser(room_id, msg.sender_id).display_name +
|
2019-03-28 09:38:48 +11:00
|
|
|
":</font> " +
|
|
|
|
msg.content
|
|
|
|
}
|
|
|
|
|
2019-03-22 14:28:14 +11:00
|
|
|
id: subtitleLabel
|
|
|
|
visible: text !== ""
|
2019-04-12 18:33:09 +10:00
|
|
|
text: Backend.models.messages[room_id].reloadThis, get_text()
|
2019-03-28 09:38:48 +11:00
|
|
|
textFormat: Text.StyledText
|
|
|
|
|
2019-03-22 14:28:14 +11:00
|
|
|
font.pixelSize: smallSize
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 1
|
|
|
|
Layout.maximumWidth: roomLabel.Layout.maximumWidth
|
2019-03-26 09:29:46 +11:00
|
|
|
|
|
|
|
topPadding: -2
|
|
|
|
bottomPadding: topPadding
|
|
|
|
leftPadding: 5
|
|
|
|
rightPadding: leftPadding
|
2019-03-22 14:28:14 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item { Layout.fillWidth: true }
|
|
|
|
}
|
|
|
|
}
|