Basic.qml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import QtQuick 2.5
  2. import Qt.labs.settings 1.0
  3. import ".."
  4. View {
  5. id: root
  6. Settings {
  7. id: basicSettings
  8. category: "Basic"
  9. property int animationDuration: 2000
  10. property int easingType: Easing.Linear
  11. }
  12. Component {
  13. id: columnComponent
  14. Item {
  15. id: column
  16. x: width * index
  17. height: parent.height
  18. width: parent.width/generalSettings.columnCount
  19. Item {
  20. id: artworkStack
  21. property var headElement
  22. property var pictureArray: []
  23. property int artworkHeight: 0
  24. property int compoundArtworkHeight: 0
  25. property bool full: artworkHeight > root.height
  26. property bool initialized: false
  27. Component.onCompleted: {
  28. columnArray.push(this)
  29. }
  30. onFullChanged: {
  31. if (!initialized) {
  32. initialized = true
  33. globalUtil.registerColumnPrimed()
  34. }
  35. }
  36. height: childrenRect.height
  37. width: parent.width
  38. function addImage() {
  39. var image = pictureDelegate.createObject(artworkStack)
  40. if (generalSettings.effect !== "" && Effects.validate(generalSettings.effect)) {
  41. image.effect = effectDelegate.createObject(artworkStack, { target: image, effect: generalSettings.effect })
  42. }
  43. artworkHeight += image.height
  44. compoundArtworkHeight += image.height
  45. image.y = root.height - compoundArtworkHeight
  46. pictureArray.push(image)
  47. globalUtil.itemCount++
  48. }
  49. function removeImage(image) {
  50. if (image.effect) {
  51. image.effect.destroy()
  52. }
  53. image.destroy()
  54. globalUtil.itemCount--
  55. }
  56. function shift() {
  57. if (headElement) {
  58. removeImage(headElement)
  59. }
  60. headElement = pictureArray.shift()
  61. artworkHeight -= headElement.height
  62. while (!full) {
  63. addImage()
  64. }
  65. artworkStack.y += headElement.height
  66. }
  67. Timer {
  68. id: populateTimer
  69. running: !artworkStack.initialized
  70. repeat: true
  71. interval: 100
  72. onTriggered: artworkStack.addImage()
  73. }
  74. Timer {
  75. id: deathTimer
  76. running: !generalSettings.commonFeed && artworkStack.initialized
  77. repeat: true
  78. interval: globalUtil.adjustedInterval
  79. onTriggered: artworkStack.shift()
  80. }
  81. Behavior on y {
  82. enabled: artworkStack.initialized
  83. NumberAnimation {
  84. duration: Math.min(globalUtil.adjustedInterval, basicSettings.animationDuration)
  85. easing.type: basicSettings.easingType
  86. }
  87. }
  88. }
  89. }
  90. }
  91. Keys.onUpPressed: generalSettings.interval++
  92. Keys.onDownPressed: generalSettings.interval = Math.max(0, generalSettings.interval - 1)
  93. }