Basic.qml 3.3 KB

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