moment/harmonyqml/components/side_pane/RoomDelegate.qml
miruka 13fca98838 Rooms and threads fixes
- Fix roomList height again, now based on model.count().
  All delegates are assumed to be the same height

- Properly update room list when a room is joined or left

- Catch exceptions happening in threads (futures), which previously
  passed silently

- Show "Empty room?" as "<i>Empty Room</i>" + gray [?] avatar
2019-04-13 08:59:10 -04:00

77 lines
2.3 KiB
QML

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.4
import "../base" as Base
MouseArea {
id: "root"
width: roomList.width
height: roomList.childrenHeight
onClicked: pageStack.show_room(
roomList.user_id,
roomList.model.get(index)
)
RowLayout {
anchors.fill: parent
id: row
spacing: 1
Base.Avatar { id: avatar; name: display_name; dimmension: root.height }
ColumnLayout {
spacing: 0
Base.HLabel {
id: roomLabel
text: display_name ? display_name : "<i>Empty room</i>"
textFormat: Text.StyledText
elide: Text.ElideRight
maximumLineCount: 1
Layout.maximumWidth: row.width - row.spacing - avatar.width
verticalAlignment: Qt.AlignVCenter
topPadding: -2
bottomPadding: subtitleLabel.visible ? 0 : topPadding
leftPadding: 5
rightPadding: leftPadding
}
Base.HLabel {
property var msgModel: Backend.models.messages.get(room_id)
function get_text() {
if (msgModel.count < 1) { return "" }
var msg = msgModel.get(-1)
var color_ = (msg.sender_id === roomList.user_id ?
"darkblue" : "purple")
var client = Backend.clientManager.clients[RoomList.for_user_id]
return "<font color=\"" + color_ + "\">" +
client.getUser(room_id, msg.sender_id).display_name +
":</font> " +
msg.content
}
id: subtitleLabel
visible: text !== ""
text: msgModel.reloadThis, get_text()
textFormat: Text.StyledText
font.pixelSize: smallSize
elide: Text.ElideRight
maximumLineCount: 1
Layout.maximumWidth: roomLabel.Layout.maximumWidth
topPadding: -2
bottomPadding: topPadding
leftPadding: 5
rightPadding: leftPadding
}
}
Item { Layout.fillWidth: true }
}
}