moment/harmonyqml/components/side_pane/RoomDelegate.qml

71 lines
2.0 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
import "../base" as Base
import "utils.js" as SidePaneJS
2019-03-22 14:28:14 +11:00
MouseArea {
2019-03-26 09:29:46 +11:00
id: "root"
width: roomList.width
height: roomList.childrenHeight
2019-03-22 14:28:14 +11:00
onClicked: pageStack.show_room(
2019-04-15 02:56:30 +10:00
roomList.for_user_id,
roomList.model.get(index)
)
2019-03-22 14:28:14 +11:00
RowLayout {
anchors.fill: parent
id: row
spacing: 1
Base.Avatar { id: avatar; name: display_name; dimmension: root.height }
2019-03-22 14:28:14 +11:00
ColumnLayout {
spacing: 0
Base.HLabel {
2019-03-22 14:28:14 +11:00
id: roomLabel
text: display_name ? display_name : "<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.spacing - avatar.width
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 get_text() {
return SidePaneJS.get_last_room_event_text(room_id)
}
Connections {
target: Backend.models.roomEvents.get(room_id)
onChanged: subtitleLabel.text = subtitleLabel.get_text()
}
2019-03-22 14:28:14 +11:00
id: subtitleLabel
visible: text !== ""
text: get_text()
textFormat: Text.StyledText
2019-03-22 14:28:14 +11:00
font.pixelSize: smallSize
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 }
}
}