main.qml 3.1 KB

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