moment/harmonyqml/components/SidePane/RoomDelegate.qml

74 lines
2.1 KiB
QML
Raw Normal View History

2019-03-22 14:28:14 +11:00
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.4
2019-04-29 02:45:12 +10:00
import "../Base" as Base
import "utils.js" as SidePaneJS
2019-03-22 14:28:14 +11:00
MouseArea {
id: roomDelegate
width: roomList.width
height: roomList.childrenHeight
2019-03-22 14:28:14 +11:00
onClicked: pageStack.showRoom(roomList.userId, roomId)
Base.HRowLayout {
2019-03-22 14:28:14 +11:00
anchors.fill: parent
id: row
spacing: 1
Base.HAvatar {
id: roomAvatar
name: displayName
dimension: roomDelegate.height
}
2019-03-22 14:28:14 +11:00
Base.HColumnLayout {
Base.HLabel {
2019-03-22 14:28:14 +11:00
id: roomLabel
text: displayName ? displayName : "<i>Empty room</i>"
textFormat: Text.StyledText
2019-03-22 14:28:14 +11:00
elide: Text.ElideRight
maximumLineCount: 1
Layout.maximumWidth:
row.width - row.totalSpacing - roomAvatar.width
2019-03-22 14:28:14 +11:00
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
}
Base.HLabel {
function getText() {
2019-04-22 10:55:24 +10:00
return SidePaneJS.getLastRoomEventText(
roomId, roomList.userId
2019-04-22 10:55:24 +10:00
)
}
Connections {
target: Backend.models.roomEvents.get(roomId)
onChanged: subtitleLabel.text = subtitleLabel.getText()
}
2019-03-22 14:28:14 +11:00
id: subtitleLabel
visible: text !== ""
text: getText()
textFormat: Text.StyledText
2019-04-27 06:02:20 +10:00
font.pixelSize: Base.HStyle.fontSize.small
2019-03-22 14:28:14 +11:00
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 }
}
}