Basic.qml 3.3 KB

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