chore(qml): adapt assets to support mediaserver images

This commit is contained in:
Patryk Osmaczko 2023-06-07 13:37:44 +02:00 committed by osmaczko
parent 216a5511f2
commit dfbac49302
12 changed files with 18 additions and 16 deletions

View File

@ -76,7 +76,7 @@ Item {
statusChatListItems.itemAtIndex(from).categoryId,
statusChatListItems.itemAtIndex(to).categoryPosition
);
} else {
root.chatItemReordered(
statusChatListItems.itemAtIndex(to).categoryId,
@ -174,7 +174,6 @@ Item {
selected: (model.active && root.highlightItem)
asset.emoji: !!model.emoji ? model.emoji : ""
asset.color: !!model.color ? model.color : Theme.palette.userCustomizationColors[model.colorId]
asset.isImage: model.icon.includes("data")
asset.name: model.icon
ringSettings.ringSpecModel: type === StatusChatListItem.Type.OneToOneChat && root.isEnsVerified(chatId) ? undefined : model.colorHash
onlineStatus: !!model.onlineStatus ? model.onlineStatus : StatusChatListItem.OnlineStatus.Inactive

View File

@ -24,8 +24,12 @@ Loader {
distinctiveColors: Theme.palette.identiconRingColors
}
sourceComponent: root.loading ? loadingComp : (root.asset.isLetterIdenticon || root.asset.name === "") ? letterIdenticon :
!root.asset.isImage ? roundedIcon : roundedImage
sourceComponent: {
if (root.loading) return loadingComp
if (root.asset.isLetterIdenticon || root.asset.name === "") return letterIdenticon
if (root.asset.isImage) return roundedImage
return roundedIcon
}
property bool loading: false
property bool hoverEnabled: false

View File

@ -33,10 +33,16 @@ QtObject {
property int bgBorderWidth: 0
//image
property bool isImage: false
property bool isImage: isImgSrc(root.name)
property int imgStatus
property bool imgIsIdenticon: false
// ring settings hints
readonly property real ringPxSize: Math.max(1.5, root.width / 24.0)
function isImgSrc(name) {
return name.toLowerCase().startsWith("data:image") ||
name.toLowerCase().startsWith("http://") ||
name.toLowerCase().startsWith("https://")
}
}

View File

@ -20,7 +20,6 @@ QtObject {
width: root.width
height: root.height
name: root.name
isImage: name.startsWith("data")
isLetterIdenticon: (name === "")
imgIsIdenticon: root.isIdenticon
color: Theme.palette.userCustomizationColors[root.colorId]

View File

@ -20,7 +20,6 @@ StatusListItem {
asset.isLetterIdenticon: true
asset.letterSize: 12
asset.isImage: asset.name.includes("data")
asset.width: 32
asset.height: 32

View File

@ -32,7 +32,6 @@ StatusListView {
subTitle: model.description
tertiaryTitle: qsTr("%n member(s)", "", model.members.count)
asset.name: model.image
asset.isImage: asset.name.includes("data")
asset.isLetterIdenticon: !model.image
asset.bgColor: model.color || Theme.palette.primaryColor1
asset.width: 40

View File

@ -60,7 +60,6 @@ StatusListItem {
asset.letterSize: asset._twoLettersSize
asset.charactersLen: 2
asset.name: root.iconSource
asset.isImage: asset.name.includes("data")
asset.isLetterIdenticon: root.iconSource.toString() === ""
ringSettings {
ringSpecModel: Utils.getColorHashAsJson(root.publicKey, root.ensVerified)

View File

@ -47,7 +47,6 @@ ModalPopup {
asset.width: 40
asset.height: 40
asset.name: model.icon
asset.isImage: asset.name.includes("data")
asset.isLetterIdenticon: asset.name === ""
asset.letterSize: 15
asset.color: Theme.palette.miscColor5

View File

@ -885,7 +885,7 @@ Item {
value: true
restoreMode: Binding.RestoreNone
}
Component {
id: loadingStateComponent
Item {
@ -902,7 +902,7 @@ Item {
}
}
}
Component {
id: errorStateComponent
Item {
@ -1274,7 +1274,6 @@ Item {
asset.height: 30
asset.color: modelData ? modelData.color : ""
asset.name: modelData ? modelData.icon : ""
asset.isImage: asset.name.includes("data")
}
onAboutToShow: rootStore.rebuildChatSearchModel()

View File

@ -36,7 +36,6 @@ ActivityNotificationBase {
width: 40
height: 40
name: contactDetails ? contactDetails.displayIcon : ""
assetSettings.isImage: contactDetails && contactDetails.displayIcon.startsWith("data")
pubkey: contactId
colorId: Utils.colorIdForPubkey(contactId)
colorHash: Utils.getColorHashAsJson(contactId, sender.isEnsVerified)

View File

@ -46,6 +46,7 @@ Item {
Property holds asset settings for contact icon.
*/
property StatusAssetSettings asset: StatusAssetSettings {
id: statusAssetSettings
width: 36
height: 36
color: d.isContact ? Utils.colorForPubkey(root.contactPubKey) : d.walletAddressColor
@ -57,7 +58,7 @@ Item {
}
return ""
}
isImage: d.isContact && d.contactData.displayIcon.includes("data")
isImage: d.isContact && statusAssetSettings.isImgSrc(d.contactData.displayIcon)
emoji: d.isWallet && !!d.walletAddressEmoji ? d.walletAddressEmoji : ""
isLetterIdenticon: d.isContact && !isImage
charactersLen: 2

View File

@ -602,7 +602,6 @@ Loader {
width: 40
height: 40
name: root.senderIcon || ""
assetSettings.isImage: root.isDiscordMessage || root.senderIcon.startsWith("data")
pubkey: root.senderId
colorId: Utils.colorIdForPubkey(root.senderId)
colorHash: root.senderColorHash