1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-05 18:22:46 +00:00

Give fallback images random background colours

[UI] Added: if an image cannot be loaded, it will have a random background colour.
This commit is contained in:
Chris Josten 2020-10-01 12:55:11 +02:00
parent 5057867ade
commit 7221fda1d5
4 changed files with 26 additions and 19 deletions

View file

@ -59,6 +59,7 @@ BaseDetailPage {
id: itemImage
anchors.fill: parent
source: Utils.itemModelImageUrl(ApiClient.baseUrl, model.id, model.imageTags["Primary"], "Primary", {"maxWidth": width})
fallbackColor: Utils.colorFromString(model.name)
fillMode: Image.PreserveAspectCrop
clip: true
}
@ -68,7 +69,7 @@ BaseDetailPage {
bottom: parent.bottom
right: parent.right
}
height: itemName.height + Theme.paddingSmall * 2
height: itemName.height + Theme.paddingMedium * 2
visible: itemImage.status !== Image.Null
}
Label {
@ -86,15 +87,7 @@ BaseDetailPage {
horizontalAlignment: Text.AlignLeft
font.pixelSize: Theme.fontSizeSmall
}
onClicked: {
switch(model.type) {
case "Folder":
pageStack.push(Qt.resolvedUrl("CollectionPage.qml"), {"itemId": model.id})
break;
default:
pageStack.push(Utils.getPageUrl(model.mediaType, model.type), {"itemId": model.id})
}
}
onClicked: pageStack.push(Utils.getPageUrl(model.mediaType, model.type), {"itemId": model.id})
}
ViewPlaceholder {