ArtImage.qml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import QtQuick 2.5
  2. import PictureModel 1.0
  3. import ".."
  4. Rectangle {
  5. id: root
  6. property var effect
  7. property int modelIndex
  8. color: "black"
  9. height: Math.ceil(width/imageModel.data(modelIndex, PictureModel.RatioRole))
  10. width: parent.width
  11. Image {
  12. id: image
  13. opacity: 0
  14. anchors.fill: parent
  15. asynchronous: true
  16. fillMode: Image.PreserveAspectFit
  17. source: imageModel.data(modelIndex)
  18. mirror: globalSettings.randomlyMirrorArt && (Math.random() < 0.5)
  19. smooth: globalSettings.smoothArt
  20. sourceSize.height: height
  21. sourceSize.width: width
  22. Behavior on opacity {
  23. NumberAnimation { duration: 1000 }
  24. }
  25. onStatusChanged: {
  26. if (status === Image.Ready) {
  27. opacity = 1
  28. }
  29. }
  30. }
  31. Component.onCompleted: {
  32. modelIndex = Math.floor(Math.random()*imageModel.count)
  33. if (globalSettings.effect !== "" && Effects.validate(globalSettings.effect)) {
  34. var component = Qt.createComponent("VisualEffect.qml");
  35. component.status !== Component.Ready && console.log('Component failed with:' + effectDelegate.errorString())
  36. root.effect = component.createObject(root, { target: image, effect: globalSettings.effect })
  37. }
  38. }
  39. }