main.qml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. property string timeString
  20. function timeChanged() {
  21. var date = new Date;
  22. timeString = date.toLocaleTimeString('en-US', { hour12: false });
  23. }
  24. property variant timeTimer: Timer {
  25. interval: 1000; running: true; repeat: true;
  26. onTriggered: d.timeChanged()
  27. }
  28. }
  29. QtObject {
  30. id: globalUtil
  31. property int itemCount
  32. property int currentColumn: 0
  33. property bool primed: d.primedColumns === globalSettings.columnCount
  34. property int adjustedInterval: 1000*(globalSettings.interval > 60 ? 60*(globalSettings.interval-60) : Math.max(globalSettings.interval, 1))
  35. function registerColumnPrimed() {
  36. d.primedColumns++
  37. }
  38. function reset() {
  39. itemCount = currentColumn = d.primedColumns = 0
  40. loader.item.reset()
  41. }
  42. function columnSelection() {
  43. if (globalSettings.commonFeedRoundRobin) {
  44. var ret = currentColumn
  45. currentColumn = (currentColumn + 1) % globalSettings.columnCount
  46. return ret
  47. } else {
  48. return Math.floor(Math.random()*globalSettings.columnCount)
  49. }
  50. }
  51. }
  52. Settings {
  53. id: globalSettings
  54. property int columnCount: 5
  55. property int interval: 5
  56. property bool showViewItemCount: false
  57. property bool showScreenResolution: false
  58. property string effect: ""
  59. property string view: "Basic"
  60. property bool smoothArt: false
  61. property bool randomlyMirrorArt: true
  62. property bool fullscreen: true
  63. property bool commonFeed: true
  64. property bool commonFeedRoundRobin: true
  65. onColumnCountChanged: globalUtil.reset()
  66. Component.onCompleted: loader.source = globalSettings.view.toLowerCase() + "/" + globalSettings.view + ".qml"
  67. }
  68. Rectangle {
  69. focus: true
  70. color: "black"
  71. anchors.fill: parent
  72. Keys.forwardTo: [loader.item, toplevelhandler]
  73. Loader {
  74. id: loader
  75. anchors { top: parent.top; left: parent.left; right: parent.right; bottom: clock.top }
  76. }
  77. Rectangle {
  78. id: clock
  79. color: "black"
  80. height: appWindow.height/15
  81. anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
  82. Text {
  83. anchors.centerIn: parent
  84. color: Qt.rgba(0.3, 0.3, 0.3, 1.0)
  85. font.pixelSize: parent.height
  86. text: d.timeString
  87. }
  88. }
  89. }
  90. Rectangle {
  91. id: toplevelhandler
  92. focus: true
  93. Keys.onLeftPressed: globalSettings.columnCount = Math.max(globalSettings.columnCount-1,1)
  94. Keys.onRightPressed: globalSettings.columnCount++
  95. }
  96. Rectangle {
  97. z: 1
  98. visible: imageModel.rowCount > 0
  99. color: "red"
  100. width: childrenRect.width
  101. height: childrenRect.height
  102. anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter }
  103. Text {
  104. font.pointSize: 40
  105. text: "No images found/provided"
  106. }
  107. }
  108. Rectangle {
  109. z: 1
  110. opacity: 0.5
  111. visible: globalSettings.showViewItemCount
  112. color: "black"
  113. anchors { right: parent.right; top: parent.top }
  114. width: itemCountLabel.width
  115. height: itemCountLabel.height
  116. Text {
  117. id: itemCountLabel
  118. font.pixelSize: 100
  119. text: globalUtil.itemCount
  120. color: "white"
  121. }
  122. }
  123. Rectangle {
  124. z: 1
  125. opacity: 0.5
  126. visible: globalSettings.showScreenResolution
  127. color: "black"
  128. anchors { right: parent.right; top: parent.top }
  129. width: resolutionLabel.width
  130. height: resolutionLabel.height
  131. Text {
  132. id: resolutionLabel
  133. font.pixelSize: 100
  134. text: screenSize.width + "x" + screenSize.height
  135. color: "white"
  136. }
  137. }
  138. Component.onCompleted: {
  139. globalSettings.fullscreen ? showFullScreen() : show()
  140. }
  141. }