main.qml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 = ("00" + date.getHours()).slice(-2) + ':' + ("00" + date.getMinutes()).slice(-2);
  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 clockWidget: false
  64. property real clockIntensity: 0.6
  65. property bool commonFeed: true
  66. property bool commonFeedRoundRobin: true
  67. onColumnCountChanged: globalUtil.reset()
  68. Component.onCompleted: loader.source = globalSettings.view.toLowerCase() + "/" + globalSettings.view + ".qml"
  69. }
  70. Rectangle {
  71. focus: true
  72. color: "black"
  73. anchors.fill: parent
  74. Keys.forwardTo: [loader.item, toplevelhandler]
  75. Loader {
  76. id: loader
  77. anchors.fill: parent
  78. }
  79. Rectangle {
  80. id: clock
  81. width: childrenRect.width
  82. opacity: 0.7
  83. color: "black"
  84. visible: height > 0
  85. height: globalSettings.clockWidget ? appWindow.height/15 : 0
  86. anchors { top: parent.top; horizontalCenter: parent.horizontalCenter }
  87. Text {
  88. anchors.centerIn: parent
  89. color: "white"//Qt.rgba(globalSettings.clockIntensity, globalSettings.clockIntensity, globalSettings.clockIntensity, 1.0)
  90. font.bold: true
  91. font.pixelSize: parent.height
  92. text: d.timeString
  93. }
  94. }
  95. }
  96. Rectangle {
  97. id: toplevelhandler
  98. focus: true
  99. Keys.onLeftPressed: globalSettings.columnCount = Math.max(globalSettings.columnCount-1,1)
  100. Keys.onRightPressed: globalSettings.columnCount++
  101. }
  102. Rectangle {
  103. z: 1
  104. visible: imageModel.rowCount > 0
  105. color: "red"
  106. width: childrenRect.width
  107. height: childrenRect.height
  108. anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter }
  109. Text {
  110. font.pointSize: 40
  111. text: "No images found/provided"
  112. }
  113. }
  114. Rectangle {
  115. z: 1
  116. opacity: 0.5
  117. visible: globalSettings.showViewItemCount
  118. color: "black"
  119. anchors { right: parent.right; top: parent.top }
  120. width: itemCountLabel.width
  121. height: itemCountLabel.height
  122. Text {
  123. id: itemCountLabel
  124. font.pixelSize: 100
  125. text: globalUtil.itemCount
  126. color: "white"
  127. }
  128. }
  129. Rectangle {
  130. z: 1
  131. opacity: 0.5
  132. visible: globalSettings.showScreenResolution
  133. color: "black"
  134. anchors { right: parent.right; top: parent.top }
  135. width: resolutionLabel.width
  136. height: resolutionLabel.height
  137. Text {
  138. id: resolutionLabel
  139. font.pixelSize: 100
  140. text: screenSize.width + "x" + screenSize.height
  141. color: "white"
  142. }
  143. }
  144. Component.onCompleted: {
  145. globalSettings.fullscreen ? showFullScreen() : show()
  146. }
  147. }