main.qml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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([], { hour: '2-digit', minute:'2-digit' });
  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 { top: parent.top; left: parent.left; right: parent.right; bottom: clock.top }
  78. }
  79. Rectangle {
  80. id: clock
  81. color: "black"
  82. visible: height > 0
  83. height: globalSettings.clockWidget ? appWindow.height/15 : 0
  84. anchors { left: parent.left; right: parent.right; bottom: parent.bottom }
  85. Text {
  86. anchors.centerIn: parent
  87. color: Qt.rgba(globalSettings.clockIntensity, globalSettings.clockIntensity, globalSettings.clockIntensity, 1.0)
  88. font.pixelSize: parent.height
  89. text: d.timeString
  90. }
  91. }
  92. }
  93. Rectangle {
  94. id: toplevelhandler
  95. focus: true
  96. Keys.onLeftPressed: globalSettings.columnCount = Math.max(globalSettings.columnCount-1,1)
  97. Keys.onRightPressed: globalSettings.columnCount++
  98. }
  99. Rectangle {
  100. z: 1
  101. visible: imageModel.rowCount > 0
  102. color: "red"
  103. width: childrenRect.width
  104. height: childrenRect.height
  105. anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter }
  106. Text {
  107. font.pointSize: 40
  108. text: "No images found/provided"
  109. }
  110. }
  111. Rectangle {
  112. z: 1
  113. opacity: 0.5
  114. visible: globalSettings.showViewItemCount
  115. color: "black"
  116. anchors { right: parent.right; top: parent.top }
  117. width: itemCountLabel.width
  118. height: itemCountLabel.height
  119. Text {
  120. id: itemCountLabel
  121. font.pixelSize: 100
  122. text: globalUtil.itemCount
  123. color: "white"
  124. }
  125. }
  126. Rectangle {
  127. z: 1
  128. opacity: 0.5
  129. visible: globalSettings.showScreenResolution
  130. color: "black"
  131. anchors { right: parent.right; top: parent.top }
  132. width: resolutionLabel.width
  133. height: resolutionLabel.height
  134. Text {
  135. id: resolutionLabel
  136. font.pixelSize: 100
  137. text: screenSize.width + "x" + screenSize.height
  138. color: "white"
  139. }
  140. }
  141. Component.onCompleted: {
  142. globalSettings.fullscreen ? showFullScreen() : show()
  143. }
  144. }