Smarter adjust of messages line height
Increase line height is the message is multiline, except if there's an <img> tag in it (due to a bug in Qt, workaround will be to implement proper images support)
This commit is contained in:
parent
d0e77eb061
commit
543f7ac747
|
@ -6,7 +6,17 @@ import "../../utils.js" as Utils
|
||||||
Row {
|
Row {
|
||||||
id: eventContent
|
id: eventContent
|
||||||
spacing: theme.spacing / 2
|
spacing: theme.spacing / 2
|
||||||
// layoutDirection: onRight ? Qt.RightToLeft : Qt.LeftToRight
|
|
||||||
|
readonly property string eventText: Utils.processedEventText(model)
|
||||||
|
readonly property real lineHeight:
|
||||||
|
! eventText.match(/<img .+\/?>/) && multiline ? 1.25 : 1.0
|
||||||
|
readonly property bool multiline:
|
||||||
|
(eventText.match(/(\n|<br\/?>)/) || []).length > 0 ||
|
||||||
|
contentLabel.contentWidth < (
|
||||||
|
contentLabel.implicitWidth -
|
||||||
|
contentLabel.leftPadding -
|
||||||
|
contentLabel.rightPadding
|
||||||
|
)
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
width: hideAvatar ? 0 : 48
|
width: hideAvatar ? 0 : 48
|
||||||
|
@ -43,7 +53,6 @@ Row {
|
||||||
y: parent.height / 2 - height / 2
|
y: parent.height / 2 - height / 2
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
spacing: 0
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
HLabel {
|
HLabel {
|
||||||
|
@ -55,10 +64,11 @@ Row {
|
||||||
textFormat: Text.StyledText
|
textFormat: Text.StyledText
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
horizontalAlignment: onRight ? Text.AlignRight : Text.AlignLeft
|
horizontalAlignment: onRight ? Text.AlignRight : Text.AlignLeft
|
||||||
|
lineHeight: eventContent.lineHeight
|
||||||
|
|
||||||
leftPadding: theme.spacing
|
leftPadding: theme.spacing
|
||||||
rightPadding: leftPadding
|
rightPadding: leftPadding
|
||||||
topPadding: theme.spacing / 2
|
topPadding: theme.spacing / 2 * lineHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
HRichLabel {
|
HRichLabel {
|
||||||
|
@ -66,7 +76,7 @@ Row {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
text: theme.chat.message.styleInclude +
|
text: theme.chat.message.styleInclude +
|
||||||
Utils.processedEventText(model) +
|
eventContent.eventText +
|
||||||
// time
|
// time
|
||||||
" <font size=" + theme.fontSize.small +
|
" <font size=" + theme.fontSize.small +
|
||||||
"px color=" + theme.chat.message.date + ">" +
|
"px color=" + theme.chat.message.date + ">" +
|
||||||
|
@ -77,14 +87,14 @@ Row {
|
||||||
" <font size=" + theme.fontSize.small +
|
" <font size=" + theme.fontSize.small +
|
||||||
"px>⏳</font>" : "")
|
"px>⏳</font>" : "")
|
||||||
|
|
||||||
lineHeight: 1.3
|
lineHeight: eventContent.lineHeight
|
||||||
color: theme.chat.message.body
|
color: theme.chat.message.body
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
|
|
||||||
leftPadding: theme.spacing
|
leftPadding: theme.spacing
|
||||||
rightPadding: leftPadding
|
rightPadding: leftPadding
|
||||||
topPadding: nameLabel.visible ? 0 : bottomPadding
|
topPadding: nameLabel.visible ? 0 : bottomPadding
|
||||||
bottomPadding: theme.spacing / 2
|
bottomPadding: theme.spacing / 2 * lineHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user