Message/EventContent delegates improvements
- Rectangle > Column > Labels instead of ColumnLayout > Labels with rectangle backgrounds hack - Use basic Row and Column instead of Layouts, for simplicity and performance - Get rid of a binding loop that happened sometimes when local echo icon disappeared - Max bubble width when lots of screen space available now depends on font size, instead of always being 600
This commit is contained in:
parent
a15e2a5c9d
commit
ca04e4c4a4
@ -3,11 +3,17 @@ import QtQuick.Layouts 1.3
|
|||||||
import "../../Base"
|
import "../../Base"
|
||||||
import "../utils.js" as ChatJS
|
import "../utils.js" as ChatJS
|
||||||
|
|
||||||
HRowLayout {
|
Row {
|
||||||
id: eventContent
|
id: eventContent
|
||||||
spacing: standardSpacing / 2
|
spacing: standardSpacing / 2
|
||||||
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
|
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
|
||||||
|
|
||||||
|
width: Math.min(
|
||||||
|
roomEventListView.width - avatar.width - eventContent.spacing,
|
||||||
|
HStyle.fontSize.normal * 0.5 * 75, // 600 with 16px font
|
||||||
|
contentLabel.implicitWidth
|
||||||
|
)
|
||||||
|
|
||||||
HAvatar {
|
HAvatar {
|
||||||
id: avatar
|
id: avatar
|
||||||
name: displayName
|
name: displayName
|
||||||
@ -16,6 +22,8 @@ HRowLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HLabel {
|
HLabel {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
id: contentLabel
|
id: contentLabel
|
||||||
text: "<font color='" +
|
text: "<font color='" +
|
||||||
Qt.hsla(Backend.hueFromString(displayName.value || dict.sender),
|
Qt.hsla(Backend.hueFromString(displayName.value || dict.sender),
|
||||||
@ -41,10 +49,5 @@ HRowLayout {
|
|||||||
rightPadding: horizontalPadding
|
rightPadding: horizontalPadding
|
||||||
topPadding: verticalPadding
|
topPadding: verticalPadding
|
||||||
bottomPadding: verticalPadding
|
bottomPadding: verticalPadding
|
||||||
|
|
||||||
Layout.maximumWidth: Math.min(
|
|
||||||
600,
|
|
||||||
roomEventListView.width - avatar.width - eventContent.totalSpacing
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,27 +3,47 @@ import QtQuick.Layouts 1.3
|
|||||||
import "../../Base"
|
import "../../Base"
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: row
|
id: messageContent
|
||||||
spacing: standardSpacing / 2
|
spacing: standardSpacing / 2
|
||||||
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
|
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
|
||||||
|
|
||||||
HAvatar { id: avatar; hidden: combine; name: displayName }
|
HAvatar {
|
||||||
|
id: avatar
|
||||||
|
hidden: combine
|
||||||
|
name: displayName
|
||||||
|
}
|
||||||
|
|
||||||
HColumnLayout {
|
Rectangle {
|
||||||
|
color: HStyle.chat.message.background
|
||||||
|
|
||||||
|
//width: nameLabel.implicitWidth
|
||||||
|
width: Math.min(
|
||||||
|
roomEventListView.width - avatar.width - messageContent.spacing,
|
||||||
|
HStyle.fontSize.normal * 0.5 * 75, // 600 with 16px font
|
||||||
|
Math.max(
|
||||||
|
nameLabel.visible ? nameLabel.implicitWidth : 0,
|
||||||
|
contentLabel.implicitWidth
|
||||||
|
)
|
||||||
|
)
|
||||||
|
height: nameLabel.height + contentLabel.implicitHeight
|
||||||
|
|
||||||
|
Column {
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
HLabel {
|
HLabel {
|
||||||
visible: ! combine
|
height: combine ? 0 : implicitHeight
|
||||||
|
width: parent.width
|
||||||
|
visible: height > 0
|
||||||
|
|
||||||
id: nameLabel
|
id: nameLabel
|
||||||
text: displayName.value || dict.sender
|
text: displayName.value || dict.sender
|
||||||
background: Rectangle {color: HStyle.chat.message.background}
|
|
||||||
color: Qt.hsla(Backend.hueFromString(text),
|
color: Qt.hsla(Backend.hueFromString(text),
|
||||||
HStyle.displayName.saturation,
|
HStyle.displayName.saturation,
|
||||||
HStyle.displayName.lightness,
|
HStyle.displayName.lightness,
|
||||||
1)
|
1)
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
Layout.preferredWidth: contentLabel.width
|
|
||||||
horizontalAlignment: isOwn ? Text.AlignRight : Text.AlignLeft
|
horizontalAlignment: isOwn ? Text.AlignRight : Text.AlignLeft
|
||||||
|
|
||||||
leftPadding: horizontalPadding
|
leftPadding: horizontalPadding
|
||||||
@ -32,6 +52,8 @@ Row {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HRichLabel {
|
HRichLabel {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
id: contentLabel
|
id: contentLabel
|
||||||
text: (dict.formatted_body ?
|
text: (dict.formatted_body ?
|
||||||
Backend.htmlFilter.filter(dict.formatted_body) :
|
Backend.htmlFilter.filter(dict.formatted_body) :
|
||||||
@ -44,7 +66,6 @@ Row {
|
|||||||
" <font size=" + HStyle.fontSize.small +
|
" <font size=" + HStyle.fontSize.small +
|
||||||
"px>⏳</font>" : "")
|
"px>⏳</font>" : "")
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
background: Rectangle {color: HStyle.chat.message.background}
|
|
||||||
color: HStyle.chat.message.body
|
color: HStyle.chat.message.body
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
|
|
||||||
@ -52,11 +73,7 @@ Row {
|
|||||||
rightPadding: horizontalPadding
|
rightPadding: horizontalPadding
|
||||||
topPadding: nameLabel.visible ? 0 : verticalPadding
|
topPadding: nameLabel.visible ? 0 : verticalPadding
|
||||||
bottomPadding: verticalPadding
|
bottomPadding: verticalPadding
|
||||||
|
}
|
||||||
Layout.minimumWidth: nameLabel.implicitWidth
|
|
||||||
Layout.maximumWidth: Math.min(
|
|
||||||
600, roomEventListView.width - avatar.width - row.spacing
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user