main.qml 3.2 KB

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