main.qml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import QtQuick 2.5
  2. import QtQuick.Window 2.2
  3. import Qt.labs.settings 1.0
  4. Window {
  5. id: appWindow
  6. width: 1024
  7. height: 768
  8. onWidthChanged: globalUtil.reset()
  9. QtObject {
  10. id: d
  11. property int primedColumns: 0
  12. }
  13. QtObject {
  14. id: globalUtil
  15. property int itemCount
  16. property int currentColumn: 0
  17. property bool primed: d.primedColumns === globalSettings.columnCount
  18. property int adjustedInterval: 1000*(globalSettings.interval > 60 ? 60*(globalSettings.interval-60) : Math.max(globalSettings.interval, 1))
  19. function registerColumnPrimed() {
  20. d.primedColumns++
  21. }
  22. function reset() {
  23. itemCount = currentColumn = d.primedColumns = 0
  24. loader.item.reset()
  25. }
  26. function columnSelection() {
  27. if (globalSettings.commonFeedRoundRobin) {
  28. var ret = currentColumn
  29. currentColumn = (currentColumn + 1) % globalSettings.columnCount
  30. return ret
  31. } else {
  32. return Math.floor(Math.random()*globalSettings.columnCount)
  33. }
  34. }
  35. }
  36. Settings {
  37. id: globalSettings
  38. property int columnCount: 5
  39. property int interval: 5
  40. property bool viewItemCount: false
  41. property string effect: ""
  42. property string view: "Physics"
  43. property bool smoothArt: false
  44. property bool randomlyMirrorArt: true
  45. property bool commonFeed: true
  46. property bool commonFeedRoundRobin: true
  47. onColumnCountChanged: globalUtil.reset()
  48. Component.onCompleted: loader.source = globalSettings.view.toLowerCase() + "/" + globalSettings.view + ".qml"
  49. }
  50. Rectangle {
  51. focus: true
  52. color: "black"
  53. anchors.fill: parent
  54. Keys.forwardTo: [loader.item, toplevelhandler]
  55. Loader {
  56. id: loader
  57. anchors.fill: parent
  58. source: "basic/Basic.qml"
  59. }
  60. }
  61. Rectangle {
  62. id: toplevelhandler
  63. focus: true
  64. Keys.onLeftPressed: globalSettings.columnCount = Math.max(globalSettings.columnCount-1,1)
  65. Keys.onRightPressed: globalSettings.columnCount++
  66. }
  67. Rectangle {
  68. z: 1
  69. visible: imageModel.rowCount > 0
  70. color: "red"
  71. width: childrenRect.width
  72. height: childrenRect.height
  73. anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter }
  74. Text {
  75. font.pointSize: 40
  76. text: "No images found/provided"
  77. }
  78. }
  79. Rectangle {
  80. z: 1
  81. opacity: 0.5
  82. visible: globalSettings.viewItemCount
  83. color: "black"
  84. anchors { right: parent.right; top: parent.top }
  85. width: itemCountLabel.width
  86. height: itemCountLabel.height
  87. Text {
  88. id: itemCountLabel
  89. font.pixelSize: 100
  90. text: globalUtil.itemCount
  91. color: "white"
  92. }
  93. }
  94. Component.onCompleted: showFullScreen()
  95. }