main.qml 6.1 KB

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