1d0cce402e
For any name not found in rooms data, rely on new nio.HttpClient.get_displayname() function to get and cache it, e.g. for our own name if no room is joined and past events from users who left the room. @futurize now returns PyQtFuture objects, wrapper for the concurrent.futures.Future objects that can be used from QML, to ensure name retrieval does not block the GUI.
65 lines
2.2 KiB
QML
65 lines
2.2 KiB
QML
import QtQuick 2.7
|
|
import QtQuick.Controls 2.0
|
|
import QtQuick.Layouts 1.4
|
|
import "../base" as Base
|
|
|
|
Row {
|
|
id: row
|
|
spacing: standardSpacing
|
|
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
|
|
anchors.right: isOwn ? parent.right : undefined
|
|
|
|
Base.Avatar { id: avatar; invisible: combine; name: displayName }
|
|
|
|
ColumnLayout {
|
|
spacing: 0
|
|
|
|
Base.HLabel {
|
|
visible: ! combine
|
|
id: nameLabel
|
|
text: displayName.value || dict.sender
|
|
background: Rectangle {color: "#DDD"}
|
|
color: isOwn ? "teal" : "purple"
|
|
elide: Text.ElideRight
|
|
maximumLineCount: 1
|
|
Layout.preferredWidth: contentLabel.width
|
|
horizontalAlignment: isOwn ? Text.AlignRight : Text.AlignLeft
|
|
|
|
leftPadding: horizontalPadding
|
|
rightPadding: horizontalPadding
|
|
topPadding: verticalPadding
|
|
}
|
|
|
|
Base.RichLabel {
|
|
id: contentLabel
|
|
//text: (isOwn ? "" : content + " ") +
|
|
//"<font size=" + smallSize + "px color=gray>" +
|
|
//Qt.formatDateTime(date_time, "hh:mm:ss") +
|
|
//"</font>" +
|
|
// (isOwn ? " " + content : "")
|
|
//
|
|
text: (dict.formatted_body ?
|
|
Backend.htmlFilter.filter(dict.formatted_body) :
|
|
dict.body) +
|
|
" <font size=" + smallSize + "px color=gray>" +
|
|
Qt.formatDateTime(date_time, "hh:mm:ss") +
|
|
"</font>" +
|
|
(is_local_echo ?
|
|
" <font size=" + smallSize + "px>⏳</font>" : "")
|
|
textFormat: Text.RichText
|
|
background: Rectangle {color: "#DDD"}
|
|
wrapMode: Text.Wrap
|
|
|
|
leftPadding: horizontalPadding
|
|
rightPadding: horizontalPadding
|
|
topPadding: nameLabel.visible ? 0 : verticalPadding
|
|
bottomPadding: verticalPadding
|
|
|
|
Layout.minimumWidth: nameLabel.implicitWidth
|
|
Layout.maximumWidth: Math.min(
|
|
600, messageListView.width - avatar.width - row.spacing
|
|
)
|
|
}
|
|
}
|
|
}
|