feat(StatusLetterIdenticon): introduce strictBackgroundColor flag to decouple coloring and useAcronymForLetterIdenticon flag

This commit is contained in:
Michał Cieślak 2024-05-17 14:11:15 +02:00 committed by Michał
parent 4c61c115d4
commit aeb9929fcd
3 changed files with 14 additions and 7 deletions

View File

@ -14,12 +14,15 @@ Rectangle {
property int charactersLen: 1
property color letterIdenticonColor: Theme.palette.miscColor5
property bool useAcronymForLetterIdenticon: false
property bool strictBackgroundColor: !useAcronymForLetterIdenticon
color: {
if (root.useAcronymForLetterIdenticon) {
return Qt.rgba(root.letterIdenticonColor.r, root.letterIdenticonColor.g, root.letterIdenticonColor.b, 0.2)
}
return root.letterIdenticonColor
if (root.strictBackgroundColor)
return root.letterIdenticonColor
return Qt.rgba(root.letterIdenticonColor.r,
root.letterIdenticonColor.g,
root.letterIdenticonColor.b, 0.2)
}
width: 40
@ -33,7 +36,7 @@ Rectangle {
height: Math.round(parent.height / 2)
emojiId: Emoji.iconId(root.emoji, root.emojiSize) || Emoji.iconHex(root.emoji) || ""
}
StatusBaseText {
id: identiconText
@ -47,9 +50,9 @@ Rectangle {
font.weight: Font.Bold
font.pixelSize: root.letterSize
color: {
if (root.useAcronymForLetterIdenticon) {
if (!root.strictBackgroundColor)
return root.letterIdenticonColor
}
return d.luminance(root.letterIdenticonColor) > 0.5 ? Qt.rgba(0, 0, 0, 0.5) : Qt.rgba(1, 1, 1, 0.7)
}

View File

@ -120,6 +120,7 @@ Loader {
letterSize: root.asset.letterSize
charactersLen: root.asset.charactersLen
useAcronymForLetterIdenticon: root.asset.useAcronymForLetterIdenticon
strictBackgroundColor: root.asset.useLetterIdenticonStrictBgColor
}
}

View File

@ -13,10 +13,13 @@ QtObject {
property color hoverColor
property color disabledColor
property int rotation
property bool isLetterIdenticon
property bool useAcronymForLetterIdenticon
property bool useLetterIdenticonStrictBgColor: !useAcronymForLetterIdenticon
property int letterSize: emoji ? 11 : (charactersLen == 1 ? _oneLetterSize : _twoLettersSize)
property int charactersLen: 1
property string emoji
property string emojiSize: _emojiSize