feat(StatusRoundedImage): introduce identicon support

This just introduces a new `StatusImageSettings` property `isIdenticon`
which can be used to determine whether a `StatusRoundedImage` should
render with a background + border (which is the case for identicons).

It also updates the `StatusChatList` delegate to consider that property
and have it properly decide how to render the UI.

Closes #173
This commit is contained in:
Pascal Precht 2021-06-24 15:41:42 +02:00 committed by Pascal Precht
parent cfacd5be6d
commit 7a2648f69f
7 changed files with 32 additions and 8 deletions

View File

@ -684,7 +684,8 @@ Rectangle {
muted: false muted: false
hasUnreadMessages: false hasUnreadMessages: false
color: "green" color: "green"
identicon: "https://pbs.twimg.com/profile_images/1369221718338895873/T_5fny6o_400x400.jpg" identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAlklEQVR4nOzW0QmDQBAG4SSkl7SUQlJGCrElq9F3QdjjVhh/5nv3cFhY9vUIYQiNITSG0Bh
CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC"
unreadMessagesCount: 0 unreadMessagesCount: 0
} }
ListElement { ListElement {

View File

@ -32,7 +32,17 @@ Column {
Repeater { Repeater {
id: statusChatListItems id: statusChatListItems
delegate: StatusChatListItem { delegate: StatusChatListItem {
id: statusChatListItem id: statusChatListItem
property string profileImage: ""
Component.onCompleted: {
if (typeof statusChatList.profileImageFn === "function") {
profileImage = statusChatList.profileImageFn(model.chatId || model.id) || ""
}
}
chatId: model.chatId || model.id chatId: model.chatId || model.id
name: model.name name: model.name
type: model.chatType type: model.chatType
@ -43,13 +53,8 @@ Column {
selected: model.chatId === statusChatList.selectedChatId selected: model.chatId === statusChatList.selectedChatId
icon.color: model.color || "" icon.color: model.color || ""
image.source: { image.isIdenticon: !!!profileImage && !!!model.identityImage && !!model.identicon
let profileImage = "" image.source: profileImage || model.identityImage || model.identicon || ""
if (typeof statusChatList.profileImageFn === "function") {
profileImage = statusChatList.profileImageFn(model.chatId || model.id)
}
return profileImage || model.identityImage || model.identicon || ""
}
onClicked: { onClicked: {
if (mouse.button === Qt.RightButton && !!statusChatList.popupMenu) { if (mouse.button === Qt.RightButton && !!statusChatList.popupMenu) {

View File

@ -88,6 +88,11 @@ Rectangle {
height: parent.height height: parent.height
image.source: statusChatListItem.image.source image.source: statusChatListItem.image.source
showLoadingIndicator: true showLoadingIndicator: true
color: statusChatListItem.image.isIdenticon ?
Theme.palette.statusRoundedImage.backgroundColor :
"transparent"
border.width: statusChatListItem.image.isIdenticon ? 1 : 0
border.color: Theme.palette.directColor7
} }
Loader { Loader {

View File

@ -6,5 +6,6 @@ QtObject {
property url source property url source
property real width property real width
property real height property real height
property bool isIdenticon: false
} }

View File

@ -168,5 +168,9 @@ ThemePalette {
property QtObject statusModal: QtObject { property QtObject statusModal: QtObject {
property color backgroundColor: baseColor3 property color backgroundColor: baseColor3
} }
property QtObject statusRoundedImage: QtObject {
property color backgroundColor: baseColor3
}
} }

View File

@ -166,5 +166,9 @@ ThemePalette {
property QtObject statusModal: QtObject { property QtObject statusModal: QtObject {
property color backgroundColor: white property color backgroundColor: white
} }
property QtObject statusRoundedImage: QtObject {
property color backgroundColor: white
}
} }

View File

@ -130,6 +130,10 @@ QtObject {
property color backgroundColor property color backgroundColor
} }
property QtObject statusRoundedImage: QtObject {
property color backgroundColor
}
function alphaColor(color, alpha) { function alphaColor(color, alpha) {
let actualColor = Qt.darker(color, 1) let actualColor = Qt.darker(color, 1)
actualColor.a = alpha actualColor.a = alpha