Use Loaders for RoomEventDelegate

This commit is contained in:
miruka 2019-04-28 14:48:59 -04:00
parent 7004b4ea3f
commit 455490b5af
5 changed files with 13 additions and 17 deletions

View File

@ -1,9 +1,7 @@
- Refactoring - Refactoring
- Use new H\* components everywhere - Use totalSpacing everywhere
- TextInput.accepted() for SendBox
- Migrate more JS functions to their own files / Implement in Python instead - Migrate more JS functions to their own files / Implement in Python instead
- Don't bake in size properties for components - Don't bake in size properties for components
- Better names and organization for the Message components
- Bug fixes - Bug fixes
- 100% CPU usage when hitting top edge to trigger messages loading - 100% CPU usage when hitting top edge to trigger messages loading

View File

@ -6,6 +6,4 @@ Base.HNoticeLabel {
color: Base.HStyle.chat.daybreak.foreground color: Base.HStyle.chat.daybreak.foreground
backgroundColor: Base.HStyle.chat.daybreak.background backgroundColor: Base.HStyle.chat.daybreak.background
radius: Base.HStyle.chat.daybreak.radius radius: Base.HStyle.chat.daybreak.radius
width: roomEventDelegate.width
} }

View File

@ -5,13 +5,9 @@ import "../../Base" as Base
import "../utils.js" as ChatJS import "../utils.js" as ChatJS
RowLayout { RowLayout {
id: row id: eventContent
spacing: standardSpacing / 2 spacing: standardSpacing / 2
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
anchors.right: isOwn ? parent.right : undefined
readonly property string contentText:
isMessage ? "" : ChatJS.getEventText(type, dict)
Base.HAvatar { Base.HAvatar {
id: avatar id: avatar
@ -29,7 +25,7 @@ RowLayout {
1) + 1) +
"'>" + "'>" +
(displayName.value || dict.sender) + " " + (displayName.value || dict.sender) + " " +
contentText + ChatJS.getEventText(type, dict) +
"  " + "  " +
"<font size=" + Base.HStyle.fontSize.small + "px " + "<font size=" + Base.HStyle.fontSize.small + "px " +
@ -48,7 +44,8 @@ RowLayout {
bottomPadding: verticalPadding bottomPadding: verticalPadding
Layout.maximumWidth: Math.min( Layout.maximumWidth: Math.min(
600, roomEventListView.width - avatar.width - row.spacing 600,
roomEventListView.width - avatar.width - eventContent.totalSpacing
) )
} }
} }

View File

@ -7,7 +7,6 @@ Row {
id: row id: row
spacing: standardSpacing spacing: standardSpacing
layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight layoutDirection: isOwn ? Qt.RightToLeft : Qt.LeftToRight
anchors.right: isOwn ? parent.right : undefined
Base.HAvatar { id: avatar; hidden: combine; name: displayName } Base.HAvatar { id: avatar; hidden: combine; name: displayName }

View File

@ -72,7 +72,10 @@ Column {
combine ? standardSpacing / 4 : combine ? standardSpacing / 4 :
standardSpacing standardSpacing
Daybreak { visible: dayBreak } Loader {
source: dayBreak ? "Daybreak.qml" : ""
width: roomEventDelegate.width
}
Item { Item {
visible: dayBreak visible: dayBreak
@ -80,7 +83,8 @@ Column {
height: topPadding height: topPadding
} }
MessageContent { visible: isMessage } Loader {
source: isMessage ? "MessageContent.qml" : "EventContent.qml"
EventContent { visible: ! isMessage } anchors.right: isOwn ? parent.right : undefined
}
} }