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
- Use new H\* components everywhere
- TextInput.accepted() for SendBox
- Use totalSpacing everywhere
- Migrate more JS functions to their own files / Implement in Python instead
- Don't bake in size properties for components
- Better names and organization for the Message components
- Bug fixes
- 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
backgroundColor: Base.HStyle.chat.daybreak.background
radius: Base.HStyle.chat.daybreak.radius
width: roomEventDelegate.width
}

View File

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

View File

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