12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import QtQuick 2.5
- import PictureModel 1.0
- import ".."
- Rectangle {
- id: root
- property var effect
- property int modelIndex
- property alias asynchronous: image.asynchronous
- property alias source: image.source
- color: globalSettings.randomBackdropColor ? Qt.rgba(Math.random(255), Math.random(255), Math.random(255), 1.0) : "black"
- height: width*nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height/nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width
- width: globalVars.imageWidthOverride
- Image {
- id: image
- cache: false
- opacity: globalSettings.fadeInImages ? 0 : 1.0
- height: root.height
- width: root.width
- asynchronous: true
- fillMode: Image.PreserveAspectFit
- source: nativeUtils.imageCollection.data(modelIndex)
- mirror: globalSettings.randomlyMirrorArt && (Math.random() < globalSettings.randomlyMirrorArtFreq)
- smooth: true
- mipmap: false
- sourceSize.height: height
- sourceSize.width: width
- Behavior on opacity {
- enabled: image.asynchronous
- SequentialAnimation {
- ScriptAction { script: root.effect !== undefined ? root.effect.scheduleUpdate() : undefined }
- NumberAnimation { duration: 1000 }
- }
- }
- onStatusChanged: {
- if (status === Image.Ready) {
- opacity = globalSettings.artOpacity
- }
- }
- }
- Component.onCompleted: {
- modelIndex = nativeUtils.imageCollection.requestIndex()
- if (globalSettings.effect !== "" && Effects.validate(globalSettings.effect)) {
- var component = Qt.createComponent("VisualEffect.qml");
- component.status !== Component.Ready && console.log('Component failed with:' + component.errorString())
- root.effect = component.createObject(root, { target: image, effect: globalSettings.effect })
- }
- }
- Component.onDestruction: nativeUtils.imageCollection.retireIndex(modelIndex)
- }
|