feat(StatusListItem): support letter identicons

This adds support for letter identicons by using the `icon.isLetterIdenticon`
flag:

```qml
StatusListItem {
    title: "Some name"
    icon.isLetterIdenticon: true
    icon.background.color: "orange"
}
```

Closes #239
This commit is contained in:
Pascal Precht 2021-07-08 12:39:46 +02:00 committed by Pascal Precht
parent 51a345866a
commit 531e54f238
3 changed files with 27 additions and 2 deletions

View File

@ -230,6 +230,12 @@ GridLayout {
type: StatusListItem.Type.Secondary
}
StatusListItem {
title: "Title"
icon.isLetterIdenticon: true
icon.background.color: "orange"
}
StatusDescriptionListItem {
title: "Title"
subTitle: "Subtitle"

View File

@ -34,6 +34,7 @@ Rectangle {
height: 20
width: 20
rotation: 0
isLetterIdenticon: false
background: StatusIconBackgroundSettings {
width: 40
height: 40
@ -78,8 +79,15 @@ Rectangle {
anchors.left: parent.left
anchors.leftMargin: statusListItem.leftPadding
anchors.verticalCenter: parent.verticalCenter
sourceComponent: !!statusListItem.icon.name ? statusRoundedIcon : statusRoundedImage
active: !!statusListItem.icon.name || !!statusListItem.image.source.toString()
sourceComponent: {
if (statusListItem.icon.isLetterIdenticon) {
return statusLetterIdenticon
}
return !!statusListItem.icon.name ? statusRoundedIcon : statusRoundedImage
}
active: statusListItem.icon.isLetterIdenticon ||
!!statusListItem.icon.name ||
!!statusListItem.image.source.toString()
}
Component {
@ -104,6 +112,16 @@ Rectangle {
}
}
Component {
id: statusLetterIdenticon
StatusLetterIdenticon {
width: statusListItem.icon.background.width
height: statusListItem.icon.background.height
color: statusListItem.icon.background.color
name: statusListItem.title
}
}
Item {
anchors.left: iconOrImage.active ? iconOrImage.right : parent.left
anchors.leftMargin: statusListItem.leftPadding

View File

@ -10,5 +10,6 @@ QtObject {
property color color
property url source
property int rotation
property bool isLetterIdenticon
property StatusIconBackgroundSettings background: StatusIconBackgroundSettings {}
}