moment/src/qml/SidePane/RoomDelegate.qml

66 lines
1.9 KiB
QML
Raw Normal View History

2019-03-22 14:28:14 +11:00
import QtQuick 2.7
import QtQuick.Layouts 1.3
import "../Base"
import "../utils.js" as Utils
2019-03-22 14:28:14 +11:00
MouseArea {
id: roomDelegate
width: roomList.width
height: childrenRect.height
2019-03-22 14:28:14 +11:00
onClicked:
pageStack.showRoom(roomList.userId, roomList.category, model.roomId)
HRowLayout {
width: parent.width
spacing: sidePane.normalSpacing
2019-03-22 14:28:14 +11:00
HAvatar {
id: roomAvatar
name: Utils.stripRoomName(model.displayName)
}
2019-03-22 14:28:14 +11:00
HColumnLayout {
Layout.fillWidth: true
Layout.maximumWidth:
parent.width - parent.totalSpacing - roomAvatar.width
HLabel {
2019-03-22 14:28:14 +11:00
id: roomLabel
text: model.displayName || "<i>Empty room</i>"
textFormat: model.displayName? Text.PlainText : Text.StyledText
2019-03-22 14:28:14 +11:00
elide: Text.ElideRight
maximumLineCount: 1
verticalAlignment: Qt.AlignVCenter
2019-03-26 09:29:46 +11:00
Layout.maximumWidth: parent.width
2019-03-22 14:28:14 +11:00
}
HRichLabel {
id: subtitleLabel
visible: Boolean(text)
textFormat: Text.StyledText
text: {
var ev = models.timelines.lastEventOf(model.roomId)
if (! ev) { return "" }
if (! Utils.eventIsMessage(ev)) {
return Utils.translatedEventContent(ev)
}
return Utils.coloredNameHtml(
models.users.getUser(ev.senderId).displayName,
ev.senderId
) + ": " + py.callSync("inlinify", [ev.content])
}
font.pixelSize: HStyle.fontSize.small
elide: Text.ElideRight
maximumLineCount: 1
Layout.maximumWidth: parent.width
}
2019-03-22 14:28:14 +11:00
}
}
}