main.qml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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: globalVars
  18. property real imageWidthOverride: -1
  19. }
  20. QtObject {
  21. id: d
  22. property int primedColumns: 0
  23. property string timeString
  24. property string day
  25. property string month
  26. function timeChanged() {
  27. var date = new Date;
  28. timeString = Qt.formatDateTime(date, "hh:mm")
  29. day = Qt.formatDateTime(date, "dd")
  30. month = Qt.formatDateTime(date, "MM")
  31. }
  32. property variant timeTimer: Timer {
  33. interval: 1000; running: true; repeat: true;
  34. onTriggered: d.timeChanged()
  35. }
  36. }
  37. QtObject {
  38. id: globalUtil
  39. property int itemCount
  40. property int currentColumn: 0
  41. property bool primed: d.primedColumns === globalSettings.columnCount
  42. property int adjustedInterval: 1000*(globalSettings.interval > 60 ? 60*(globalSettings.interval-60) : Math.max(globalSettings.interval, 1))
  43. function registerColumnPrimed() {
  44. d.primedColumns++
  45. }
  46. function reset() {
  47. itemCount = currentColumn = d.primedColumns = 0
  48. loader.item.reset()
  49. }
  50. function columnSelection() {
  51. if (globalSettings.commonFeedRoundRobin) {
  52. var ret = currentColumn
  53. currentColumn = (currentColumn + 1) % globalSettings.columnCount
  54. return ret
  55. } else {
  56. return Math.floor(Math.random()*globalSettings.columnCount)
  57. }
  58. }
  59. }
  60. Settings {
  61. id: globalSettings
  62. property int columnCount: 5
  63. property int interval: 5
  64. property bool showViewItemCount: false
  65. property bool showScreenResolution: false
  66. property string effect: ""
  67. property string view: "Cascade"
  68. property bool smoothArt: true
  69. property bool randomlyMirrorArt: false
  70. property bool fullscreen: true
  71. property bool clockWidget: false
  72. property real clockIntensity: 0.6
  73. property bool commonFeed: true
  74. property bool commonFeedRoundRobin: true
  75. property real artOpacity: 1.0
  76. property bool randomTapestryColour: false
  77. property bool fadeInImages: true
  78. onColumnCountChanged: globalUtil.reset()
  79. Component.onCompleted: loader.source = globalSettings.view.toLowerCase() + "/" + globalSettings.view + ".qml"
  80. }
  81. Rectangle {
  82. focus: true
  83. color: "black"
  84. anchors.fill: parent
  85. Keys.forwardTo: [loader.item, toplevelhandler]
  86. Loader {
  87. id: loader
  88. anchors.fill: parent
  89. }
  90. Rectangle {
  91. id: clock
  92. width: childrenRect.width
  93. opacity: 0.7
  94. color: "black"
  95. visible: height > 0
  96. height: globalSettings.clockWidget ? appWindow.height/15 : 0
  97. anchors { top: parent.top; horizontalCenter: parent.horizontalCenter }
  98. Text {
  99. //anchors.centerIn: parent
  100. id: clockLabel
  101. color: "white"
  102. font.bold: true
  103. font.pixelSize: parent.height
  104. text: d.timeString
  105. }
  106. Item {
  107. anchors { left: clockLabel.right; leftMargin: 20 }
  108. height: clock.height
  109. width: childrenRect.width
  110. Item {
  111. width: childrenRect.width
  112. height: parent.height/2
  113. Text {
  114. anchors.centerIn: parent
  115. color: "white"
  116. font.bold: true
  117. verticalAlignment: Text.AlignVCenter
  118. horizontalAlignment: Text.AlignHCenter
  119. font.pixelSize: clock.height/3
  120. text: d.day
  121. }
  122. }
  123. Item {
  124. y: parent.height/2
  125. width: childrenRect.width
  126. height: parent.height/2
  127. Text {
  128. anchors.centerIn: parent
  129. color: "white"
  130. font.bold: true
  131. verticalAlignment: Text.AlignVCenter
  132. horizontalAlignment: Text.AlignHCenter
  133. font.pixelSize: clock.height/3
  134. text: d.month
  135. }
  136. }
  137. }
  138. }
  139. }
  140. Rectangle {
  141. id: toplevelhandler
  142. focus: true
  143. Keys.onLeftPressed: globalSettings.columnCount = Math.max(globalSettings.columnCount-1,1)
  144. Keys.onRightPressed: globalSettings.columnCount++
  145. Keys.onEscapePressed: Qt.quit()
  146. }
  147. Rectangle {
  148. z: 1
  149. visible: imageModel.rowCount > 0
  150. color: "red"
  151. width: childrenRect.width
  152. height: childrenRect.height
  153. anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter }
  154. Text {
  155. font.pointSize: 40
  156. text: "No images found/provided"
  157. }
  158. }
  159. Rectangle {
  160. z: 1
  161. opacity: 0.5
  162. visible: globalSettings.showViewItemCount
  163. color: "black"
  164. anchors { right: parent.right; top: parent.top }
  165. width: itemCountLabel.width
  166. height: itemCountLabel.height
  167. Text {
  168. id: itemCountLabel
  169. font.pixelSize: 100
  170. text: globalUtil.itemCount
  171. color: "white"
  172. }
  173. }
  174. Rectangle {
  175. z: 1
  176. opacity: 0.5
  177. visible: globalSettings.showScreenResolution
  178. color: "black"
  179. anchors { right: parent.right; top: parent.top }
  180. width: resolutionLabel.width
  181. height: resolutionLabel.height
  182. Text {
  183. id: resolutionLabel
  184. font.pixelSize: 100
  185. text: screenSize.width + "x" + screenSize.height
  186. color: "white"
  187. }
  188. }
  189. Component.onCompleted: {
  190. globalSettings.fullscreen ? showFullScreen() : show()
  191. }
  192. }