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