Basic.qml 3.2 KB

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