1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 18:52:30 +01:00
ScreenPlay/ScreenPlayWorkshop/qml/ScreenPlayItemImage.qml

64 lines
1.3 KiB
QML
Raw Normal View History

import QtQuick
2020-08-20 17:21:09 +02:00
Item {
id: screenPlayItemImage
property string sourceImage
property string sourceImageGIF
2021-05-16 19:37:55 +02:00
width: 320
height: 121
state: "loading"
2020-08-20 17:21:09 +02:00
Image {
id: image
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
source: screenPlayItemImage.sourceImage.trim()
onStatusChanged: {
if (image.status === Image.Ready) {
2021-05-16 19:37:55 +02:00
screenPlayItemImage.state = "loaded";
2020-08-20 17:21:09 +02:00
} else if (image.status === Image.Error) {
2021-05-16 19:37:55 +02:00
source = "images/missingPreview.png";
screenPlayItemImage.state = "loaded";
2020-08-20 17:21:09 +02:00
}
}
}
states: [
State {
name: "loading"
PropertyChanges {
target: image
opacity: 0
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
},
State {
name: "loaded"
PropertyChanges {
target: image
opacity: 1
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
}
]
transitions: [
Transition {
from: "loading"
to: "loaded"
NumberAnimation {
target: image
property: "opacity"
duration: 300
easing.type: Easing.InOutQuad
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
}
]
}