moment/src/qml/SidePane/RoomDelegate.qml

83 lines
2.4 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-07-13 07:06:37 +10:00
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
import "../utils.js" as Utils
2019-03-22 14:28:14 +11:00
HInteractiveRectangle {
id: roomDelegate
width: roomList.width
height: childrenRect.height
2019-03-22 14:28:14 +11:00
2019-07-13 07:06:37 +10:00
TapHandler {
onTapped: pageStack.showRoom(
roomList.userId, roomList.category, model.roomId
)
}
2019-03-22 14:28:14 +11:00
2019-07-13 07:06:37 +10:00
Row {
width: parent.width - leftPadding * 2
2019-07-13 07:06:37 +10:00
padding: sidePane.currentSpacing / 2
leftPadding: sidePane.currentSpacing
rightPadding: 0
2019-07-13 07:06:37 +10:00
HRowLayout {
width: parent.width
spacing: sidePane.currentSpacing
2019-03-26 09:29:46 +11:00
2019-07-13 07:06:37 +10:00
HRoomAvatar {
id: roomAvatar
2019-07-18 16:36:08 +10:00
userId: model.userId
2019-07-13 07:06:37 +10:00
roomId: model.roomId
2019-03-22 14:28:14 +11:00
}
2019-07-13 07:06:37 +10:00
HColumnLayout {
Layout.fillWidth: true
2019-07-13 07:06:37 +10:00
HLabel {
id: roomLabel
text: model.displayName || "<i>Empty room</i>"
textFormat:
model.displayName? Text.PlainText : Text.StyledText
elide: Text.ElideRight
verticalAlignment: Qt.AlignVCenter
Layout.fillWidth: true
}
2019-07-13 07:06:37 +10:00
HRichLabel {
function getText(ev) {
if (! ev) { return "" }
2019-07-20 10:55:52 +10:00
if (ev.eventType == "RoomMessageEmote" ||
! ev.eventType.startsWith("RoomMessage"))
{
return Utils.processedEventText(ev)
2019-07-13 07:06:37 +10:00
}
2019-07-05 06:01:44 +10:00
2019-07-13 07:06:37 +10:00
return Utils.coloredNameHtml(
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)
id: subtitleLabel
visible: Boolean(text)
textFormat: Text.StyledText
2019-07-13 07:06:37 +10:00
font.pixelSize: theme.fontSize.small
elide: Text.ElideRight
Layout.fillWidth: true
2019-07-13 07:06:37 +10:00
}
}
2019-03-22 14:28:14 +11:00
}
}
}