main.qml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.getHours() + ':' + date.getMinutes();
  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.pixelSize: parent.height
  91. text: d.timeString
  92. }
  93. }
  94. }
  95. Rectangle {
  96. id: toplevelhandler
  97. focus: true
  98. Keys.onLeftPressed: globalSettings.columnCount = Math.max(globalSettings.columnCount-1,1)
  99. Keys.onRightPressed: globalSettings.columnCount++
  100. }
  101. Rectangle {
  102. z: 1
  103. visible: imageModel.rowCount > 0
  104. color: "red"
  105. width: childrenRect.width
  106. height: childrenRect.height
  107. anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter }
  108. Text {
  109. font.pointSize: 40
  110. text: "No images found/provided"
  111. }
  112. }
  113. Rectangle {
  114. z: 1
  115. opacity: 0.5
  116. visible: globalSettings.showViewItemCount
  117. color: "black"
  118. anchors { right: parent.right; top: parent.top }
  119. width: itemCountLabel.width
  120. height: itemCountLabel.height
  121. Text {
  122. id: itemCountLabel
  123. font.pixelSize: 100
  124. text: globalUtil.itemCount
  125. color: "white"
  126. }
  127. }
  128. Rectangle {
  129. z: 1
  130. opacity: 0.5
  131. visible: globalSettings.showScreenResolution
  132. color: "black"
  133. anchors { right: parent.right; top: parent.top }
  134. width: resolutionLabel.width
  135. height: resolutionLabel.height
  136. Text {
  137. id: resolutionLabel
  138. font.pixelSize: 100
  139. text: screenSize.width + "x" + screenSize.height
  140. color: "white"
  141. }
  142. }
  143. Component.onCompleted: {
  144. globalSettings.fullscreen ? showFullScreen() : show()
  145. }
  146. }