main.qml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 showViewItemCount: false
  48. property bool showScreenResolution: false
  49. property string effect: ""
  50. property string view: "Basic"
  51. property bool smoothArt: false
  52. property bool randomlyMirrorArt: true
  53. property bool fullscreen: true
  54. property bool commonFeed: true
  55. property bool commonFeedRoundRobin: true
  56. onColumnCountChanged: globalUtil.reset()
  57. Component.onCompleted: loader.source = globalSettings.view.toLowerCase() + "/" + globalSettings.view + ".qml"
  58. }
  59. Rectangle {
  60. focus: true
  61. color: "black"
  62. anchors.fill: parent
  63. Keys.forwardTo: [loader.item, toplevelhandler]
  64. Loader {
  65. id: loader
  66. anchors.fill: parent
  67. }
  68. }
  69. Rectangle {
  70. id: toplevelhandler
  71. focus: true
  72. Keys.onLeftPressed: globalSettings.columnCount = Math.max(globalSettings.columnCount-1,1)
  73. Keys.onRightPressed: globalSettings.columnCount++
  74. }
  75. Rectangle {
  76. z: 1
  77. visible: imageModel.rowCount > 0
  78. color: "red"
  79. width: childrenRect.width
  80. height: childrenRect.height
  81. anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter }
  82. Text {
  83. font.pointSize: 40
  84. text: "No images found/provided"
  85. }
  86. }
  87. Rectangle {
  88. z: 1
  89. opacity: 0.5
  90. visible: globalSettings.showViewItemCount
  91. color: "black"
  92. anchors { right: parent.right; top: parent.top }
  93. width: itemCountLabel.width
  94. height: itemCountLabel.height
  95. Text {
  96. id: itemCountLabel
  97. font.pixelSize: 100
  98. text: globalUtil.itemCount
  99. color: "white"
  100. }
  101. }
  102. Rectangle {
  103. z: 1
  104. opacity: 0.5
  105. visible: globalSettings.showScreenResolution
  106. color: "black"
  107. anchors { right: parent.right; top: parent.top }
  108. width: resolutionLabel.width
  109. height: resolutionLabel.height
  110. Text {
  111. id: resolutionLabel
  112. font.pixelSize: 100
  113. text: screenSize.width + "x" + screenSize.height
  114. color: "white"
  115. }
  116. }
  117. Component.onCompleted: {
  118. globalSettings.fullscreen ? showFullScreen() : show()
  119. }
  120. }