FullSizedArtImage.qml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. property alias asynchronous: image.asynchronous
  9. property alias source: image.source
  10. color: globalSettings.randomBackdropColor ? Qt.rgba(Math.random(255), Math.random(255), Math.random(255), 1.0) : "black"
  11. height: width*nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height/nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width
  12. width: parent ? parent.width : 0
  13. Image {
  14. id: image
  15. cache: false
  16. opacity: globalSettings.fadeInImages ? 0 : 1.0
  17. x: globalSettings.artFrameWidth
  18. y: globalSettings.artFrameWidth
  19. height: (globalVars.imageWidthOverride > 0
  20. ? Math.ceil(globalVars.imageWidthOverride*nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height/nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width)
  21. : nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height
  22. ) - 2*globalSettings.artFrameWidth
  23. width: (globalVars.imageWidthOverride > 0
  24. ? globalVars.imageWidthOverride
  25. : nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width
  26. ) - 2*globalSettings.artFrameWidth
  27. transformOrigin: Item.TopLeft
  28. scale: (root.width - 2*globalSettings.artFrameWidth)/image.width
  29. asynchronous: true
  30. fillMode: Image.PreserveAspectFit
  31. source: nativeUtils.imageCollection.data(modelIndex)
  32. mirror: globalSettings.randomlyMirrorArt && (Math.random() < globalSettings.randomlyMirrorArtFreq)
  33. smooth: globalSettings.smoothArt
  34. mipmap: !globalSettings.smoothArt
  35. sourceSize.height: height
  36. sourceSize.width: width
  37. Behavior on opacity {
  38. enabled: image.asynchronous
  39. SequentialAnimation {
  40. ScriptAction { script: root.effect !== undefined ? root.effect.scheduleUpdate() : undefined }
  41. NumberAnimation { duration: 1000 }
  42. }
  43. }
  44. onStatusChanged: {
  45. if (status === Image.Ready) {
  46. opacity = globalSettings.artOpacity
  47. }
  48. }
  49. }
  50. Component.onCompleted: {
  51. modelIndex = nativeUtils.imageCollection.requestIndex()
  52. if (globalSettings.effect !== "" && Effects.validate(globalSettings.effect)) {
  53. var component = Qt.createComponent("VisualEffect.qml");
  54. component.status !== Component.Ready && console.log('Component failed with:' + component.errorString())
  55. root.effect = component.createObject(root, { target: image, effect: globalSettings.effect })
  56. }
  57. }
  58. Component.onDestruction: nativeUtils.imageCollection.retireIndex(modelIndex)
  59. }