Improve User Avatar Model Roles
- Update the message event and user models so that the full source url is output. - Separate the reply author into its own role - Create an empty user object that can be passed so that the QML code no longer needs to check if certain parameters exist. - Make avatarForMember return and empty QUrl if a valid avatar cannot be found and make use in the user and event models As well as cleaning up the QML this should also stop the QML Image: Media id '' doesn't follow server/mediaId pattern spam in the log.
This commit is contained in:
@@ -14,7 +14,7 @@ GridLayout {
|
||||
id: root
|
||||
property string userName
|
||||
property color userColor: Kirigami.Theme.highlightColor
|
||||
property var userAvatar: ""
|
||||
property url userAvatar: ""
|
||||
property var text
|
||||
|
||||
rows: 3
|
||||
|
||||
@@ -35,7 +35,7 @@ Components.AlbumMaximizeComponent {
|
||||
implicitHeight: Kirigami.Units.iconSizes.medium
|
||||
|
||||
name: modelData.author.name ?? modelData.author.displayName
|
||||
source: modelData.author.avatarMediaId ? ("image://mxc/" + modelData.author.avatarMediaId) : ""
|
||||
source: modelData.author.avatarSource
|
||||
color: modelData.author.color
|
||||
}
|
||||
ColumnLayout {
|
||||
|
||||
@@ -21,7 +21,7 @@ Flow {
|
||||
implicitHeight: avatarSize
|
||||
|
||||
name: modelData.displayName
|
||||
source: modelData.avatarMediaId ? ("image://mxc/" + modelData.avatarMediaId) : ""
|
||||
source: modelData.avatarSource
|
||||
color: modelData.color
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ TimelineContainer {
|
||||
width: height
|
||||
height: parent.height / 3 + 1
|
||||
name: model.author.name ?? model.author.displayName
|
||||
source: model.author.avatarMediaId ? ("image://mxc/" + model.author.avatarMediaId) : ""
|
||||
source: model.author.avatarSource
|
||||
color: model.author.color
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ QQC2.Control {
|
||||
implicitHeight: Kirigami.Units.iconSizes.small
|
||||
|
||||
name: modelData.displayName
|
||||
source: modelData.avatarMediaId ? ("image://mxc/" + modelData.avatarMediaId) : ""
|
||||
source: modelData.avatarSource
|
||||
color: modelData.color
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ QQC2.Control {
|
||||
visible: !columnLayout.folded || stateEventRepeater.count === 1
|
||||
|
||||
name: modelData.author.displayName
|
||||
avatar: modelData.author.avatarMediaId ? ("image://mxc/" + modelData.author.avatarMediaId) : ""
|
||||
avatar: modelData.author.avatarSource
|
||||
color: modelData.author.color
|
||||
text: `<style>a {text-decoration: none;}</style><a href="https://matrix.to/#/${modelData.author.id}" style="color: ${modelData.author.color}">${modelData.authorDisplayName}</a> ${modelData.text}`
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ ColumnLayout {
|
||||
Config.showAvatarInTimeline &&
|
||||
(Config.compactLayout || !showUserMessageOnRight)
|
||||
name: model.author.name ?? model.author.displayName
|
||||
source: visible && model.author.avatarMediaId ? ("image://mxc/" + model.author.avatarMediaId) : ""
|
||||
source: model.author.avatarSource
|
||||
color: model.author.color
|
||||
|
||||
MouseArea {
|
||||
@@ -144,9 +144,7 @@ ColumnLayout {
|
||||
userDetailDialog.createObject(QQC2.ApplicationWindow.overlay, {
|
||||
room: currentRoom,
|
||||
user: author.object,
|
||||
displayName: author.displayName,
|
||||
avatarMediaId: author.avatarMediaId,
|
||||
avatarUrl: author.avatarUrl
|
||||
displayName: author.displayName
|
||||
}).open();
|
||||
}
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
@@ -231,8 +229,7 @@ ColumnLayout {
|
||||
room: currentRoom,
|
||||
user: author.object,
|
||||
displayName: author.displayName,
|
||||
avatarMediaId: author.avatarMediaId,
|
||||
avatarUrl: author.avatarUrl
|
||||
avatarSource: author.avatarSource
|
||||
}).open();
|
||||
}
|
||||
}
|
||||
@@ -260,9 +257,9 @@ ColumnLayout {
|
||||
visible: active
|
||||
|
||||
sourceComponent: ReplyComponent {
|
||||
name: currentRoom.htmlSafeMemberName(reply.author.id)
|
||||
avatar: reply.author.avatarMediaId ? ("image://mxc/" + reply.author.avatarMediaId) : ""
|
||||
color: reply.author.color
|
||||
name: currentRoom.htmlSafeMemberName(model.replyAuthor.id)
|
||||
avatar: model.replyAuthor.avatarSource
|
||||
color: model.replyAuthor.color
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
||||
@@ -19,7 +19,7 @@ Kirigami.OverlaySheet {
|
||||
property var user
|
||||
|
||||
property string displayName: user.displayName
|
||||
readonly property string avatar: room.avatarForMember(user)
|
||||
readonly property url avatar: room.avatarForMember(user)
|
||||
|
||||
parent: applicationWindow().overlay
|
||||
|
||||
@@ -45,7 +45,7 @@ Kirigami.OverlaySheet {
|
||||
Layout.preferredHeight: Kirigami.Units.iconSizes.huge
|
||||
|
||||
name: displayName
|
||||
source: avatar ?? ""
|
||||
source: avatar
|
||||
color: user.color
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ Loader {
|
||||
spacing: Kirigami.Units.largeSpacing
|
||||
Kirigami.Avatar {
|
||||
id: avatar
|
||||
source: author.avatarMediaId ? ("image://mxc/" + author.avatarMediaId) : ""
|
||||
source: author.avatarSource
|
||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 3
|
||||
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
@@ -258,7 +258,7 @@ Kirigami.OverlayDrawer {
|
||||
implicitWidth: height
|
||||
sourceSize.height: Kirigami.Units.gridUnit + Kirigami.Units.smallSpacing * 2.5
|
||||
sourceSize.width: Kirigami.Units.gridUnit + Kirigami.Units.smallSpacing * 2.5
|
||||
source: avatar ? ("image://mxc/" + avatar) : ""
|
||||
source: avatar
|
||||
name: model.userId
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user