moment/src/qml/SidePane/RoomDelegate.qml

73 lines
2.1 KiB
QML
Raw Normal View History

2019-07-08 13:52:41 +10:00
// Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3.
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
2019-07-06 06:55:25 +10:00
spacing: sidePane.collapsed ? 0 : sidePane.normalSpacing
2019-03-22 14:28:14 +11:00
HRoomAvatar {
id: roomAvatar
roomId: model.roomId
}
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 {
2019-07-05 06:01:44 +10:00
function getText(ev) {
if (! ev) { return "" }
if (! Utils.eventIsMessage(ev)) {
return Utils.translatedEventContent(ev)
}
return Utils.coloredNameHtml(
2019-07-08 12:41:32 +10:00
users.find(ev.senderId).displayName,
ev.senderId
) + ": " + py.callSync("inlinify", [ev.content])
}
// Have to do it like this to avoid binding loop
property var lastEv: timelines.lastEventOf(model.roomId)
onLastEvChanged: text = getText(lastEv)
2019-07-05 06:01:44 +10:00
id: subtitleLabel
visible: Boolean(text)
textFormat: Text.StyledText
font.pixelSize: theme.fontSize.small
elide: Text.ElideRight
maximumLineCount: 1
Layout.maximumWidth: parent.width
}
2019-03-22 14:28:14 +11:00
}
}
}