Basic.qml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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/globalSettings.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. artworkHeight += image.height
  41. compoundArtworkHeight += image.height
  42. image.y = root.height - compoundArtworkHeight
  43. pictureArray.push(image)
  44. globalUtil.itemCount++
  45. }
  46. function removeImage(image) {
  47. image.destroy()
  48. globalUtil.itemCount--
  49. }
  50. function shift() {
  51. if (headElement) {
  52. removeImage(headElement)
  53. }
  54. headElement = pictureArray.shift()
  55. artworkHeight -= headElement.height
  56. while (!full) {
  57. addImage()
  58. }
  59. artworkStack.y += headElement.height
  60. }
  61. Timer {
  62. id: populateTimer
  63. running: !artworkStack.initialized
  64. repeat: true
  65. interval: 100
  66. onTriggered: artworkStack.addImage()
  67. }
  68. Timer {
  69. id: deathTimer
  70. running: !globalSettings.commonFeed && artworkStack.initialized
  71. repeat: true
  72. interval: globalUtil.adjustedInterval
  73. onTriggered: artworkStack.shift()
  74. }
  75. Behavior on y {
  76. enabled: artworkStack.initialized
  77. NumberAnimation {
  78. duration: Math.min(globalUtil.adjustedInterval, basicSettings.animationDuration)
  79. easing.type: basicSettings.easingType
  80. }
  81. }
  82. }
  83. }
  84. }
  85. Keys.onUpPressed: globalSettings.interval++
  86. Keys.onDownPressed: globalSettings.interval = Math.max(1, globalSettings.interval - 1)
  87. }