main.qml 3.0 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. QtObject {
  9. id: d
  10. property int primedColumns: 0
  11. }
  12. QtObject {
  13. id: globalVars
  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) : generalSettings.interval)*(Math.random()+1)
  20. function registerColumnPrimed() {
  21. d.primedColumns++
  22. }
  23. function reset() {
  24. itemCount = currentColumn = d.primedColumns = 0
  25. }
  26. function columnSelection() {
  27. if (commonFeedRoundRobin) {
  28. var ret = currentColumn
  29. currentColumn = (currentColumn + 1) % columnCount
  30. return ret
  31. } else {
  32. return Math.floor(Math.random()*columnCount)
  33. }
  34. }
  35. }
  36. Settings {
  37. id: generalSettings
  38. property int columnCount: 5
  39. property int interval: 5
  40. property bool viewItemCount: false
  41. property string effect: ""
  42. property string view: "Basic"
  43. property bool smoothArt: false
  44. property bool randomlyMirrorArt: true
  45. property bool commonFeed: true
  46. property bool commonFeedRoundRobin: true
  47. onViewChanged: {
  48. loader.source = generalSettings.view.toLowerCase() + "/" + generalSettings.view + ".qml"
  49. globalVars.reset()
  50. }
  51. onColumnCountChanged: d.reset()
  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: generalSettings.columnCount = Math.max(generalSettings.columnCount-1,1)
  68. Keys.onRightPressed: generalSettings.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: generalSettings.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: globalVars.itemCount
  94. color: "white"
  95. }
  96. }
  97. Component.onCompleted: showFullScreen()
  98. }