main.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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: generalSettings.commonFeedRoundRobin
  18. property int columnCount: generalSettings.columnCount
  19. property int adjustedInterval: 1000*(generalSettings.interval > 60 ? 60*(generalSettings.interval-60) : Math.max(generalSettings.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: generalSettings
  39. property int columnCount: 5
  40. property int interval: 5
  41. property bool viewItemCount: false
  42. property string effect: ""
  43. property string view: "Basic"
  44. property bool smoothArt: false
  45. property bool randomlyMirrorArt: true
  46. property bool commonFeed: true
  47. property bool commonFeedRoundRobin: true
  48. onViewChanged: {
  49. loader.source = generalSettings.view.toLowerCase() + "/" + generalSettings.view + ".qml"
  50. globalUtil.reset()
  51. }
  52. onColumnCountChanged: globalUtil.reset()
  53. }
  54. Rectangle {
  55. focus: true
  56. color: "black"
  57. anchors.fill: parent
  58. Keys.forwardTo: [loader.item, toplevelhandler]
  59. Loader {
  60. id: loader
  61. anchors.fill: parent
  62. source: "basic/Basic.qml"
  63. }
  64. }
  65. Rectangle {
  66. id: toplevelhandler
  67. focus: true
  68. Keys.onLeftPressed: generalSettings.columnCount = Math.max(generalSettings.columnCount-1,1)
  69. Keys.onRightPressed: generalSettings.columnCount++
  70. }
  71. Rectangle {
  72. z: 1
  73. visible: imageModel.rowCount > 0
  74. color: "red"
  75. width: childrenRect.width
  76. height: childrenRect.height
  77. anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter }
  78. Text {
  79. font.pointSize: 40
  80. text: "No images found/provided"
  81. }
  82. }
  83. Rectangle {
  84. z: 1
  85. opacity: 0.5
  86. visible: generalSettings.viewItemCount
  87. color: "black"
  88. anchors { right: parent.right; top: parent.top }
  89. width: itemCountLabel.width
  90. height: itemCountLabel.height
  91. Text {
  92. id: itemCountLabel
  93. font.pixelSize: 100
  94. text: globalUtil.itemCount
  95. color: "white"
  96. }
  97. }
  98. Component.onCompleted: showFullScreen()
  99. }