Show last room message as roomDelegate subtitle

This commit is contained in:
miruka
2019-03-27 18:38:48 -04:00
parent 463dca7c55
commit c35f7f35af
5 changed files with 42 additions and 9 deletions

View File

@@ -32,8 +32,8 @@ Rectangle {
}
Base.HLabel {
id: "roomSubtitle"
text: chatPage.room.subtitle
id: "roomDescription"
text: chatPage.room.description
font.pixelSize: smallSize
elide: Text.ElideRight
maximumLineCount: 1

View File

@@ -75,12 +75,13 @@ ColumnLayout {
0
Layout.maximumHeight: Layout.minimumHeight
Layout.minimumWidth: parent.width - Layout.leftMargin * 2
Layout.minimumWidth:
parent.width - Layout.leftMargin - Layout.rightMargin
Layout.maximumWidth: Layout.minimumWidth
Layout.margins: accountList.spacing
Layout.leftMargin:
sidePane.width < 36 + Layout.margins ? 0 : Layout.margins
Layout.rightMargin: Layout.leftMargin
Layout.rightMargin: 0
}
}

View File

@@ -37,9 +37,25 @@ MouseArea {
rightPadding: leftPadding
}
Base.HLabel {
function get_text() {
var msgs = Backend.messagesModel[room_id]
if (msgs.count < 1) { return "" }
var msg = msgs.get(-1)
var color_ = (msg.sender_id === roomList.user.user_id ?
"darkblue" : "purple")
return "<font color=\"" + color_ + "\">" +
Backend.getUser(msg.sender_id).display_name +
":</font> " +
msg.content
}
id: subtitleLabel
visible: text !== ""
text: subtitle
text: Backend.messagesModel[room_id].reloadThis, get_text()
textFormat: Text.StyledText
font.pixelSize: smallSize
elide: Text.ElideRight
maximumLineCount: 1