main.qml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 bool loadFullImage: false
  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: "Well"
  68. property bool smoothArt: false
  69. property bool randomlyMirrorArt: true
  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. onColumnCountChanged: globalUtil.reset()
  76. Component.onCompleted: loader.source = globalSettings.view.toLowerCase() + "/" + globalSettings.view + ".qml"
  77. }
  78. Rectangle {
  79. focus: true
  80. color: "black"
  81. anchors.fill: parent
  82. Keys.forwardTo: [loader.item, toplevelhandler]
  83. Loader {
  84. id: loader
  85. anchors.fill: parent
  86. }
  87. Rectangle {
  88. id: clock
  89. width: childrenRect.width
  90. opacity: 0.7
  91. color: "black"
  92. visible: height > 0
  93. height: globalSettings.clockWidget ? appWindow.height/15 : 0
  94. anchors { top: parent.top; horizontalCenter: parent.horizontalCenter }
  95. Text {
  96. //anchors.centerIn: parent
  97. id: clockLabel
  98. color: "white"
  99. font.bold: true
  100. font.pixelSize: parent.height
  101. text: d.timeString
  102. }
  103. Item {
  104. anchors { left: clockLabel.right; leftMargin: 20 }
  105. height: clock.height
  106. width: childrenRect.width
  107. Item {
  108. width: childrenRect.width
  109. height: parent.height/2
  110. Text {
  111. anchors.centerIn: parent
  112. color: "white"
  113. font.bold: true
  114. verticalAlignment: Text.AlignVCenter
  115. horizontalAlignment: Text.AlignHCenter
  116. font.pixelSize: clock.height/3
  117. text: d.day
  118. }
  119. }
  120. Item {
  121. y: parent.height/2
  122. width: childrenRect.width
  123. height: parent.height/2
  124. Text {
  125. anchors.centerIn: parent
  126. color: "white"
  127. font.bold: true
  128. verticalAlignment: Text.AlignVCenter
  129. horizontalAlignment: Text.AlignHCenter
  130. font.pixelSize: clock.height/3
  131. text: d.month
  132. }
  133. }
  134. }
  135. }
  136. }
  137. Rectangle {
  138. id: toplevelhandler
  139. focus: true
  140. Keys.onLeftPressed: globalSettings.columnCount = Math.max(globalSettings.columnCount-1,1)
  141. Keys.onRightPressed: globalSettings.columnCount++
  142. Keys.onEscapePressed: Qt.quit()
  143. }
  144. Rectangle {
  145. z: 1
  146. visible: imageModel.rowCount > 0
  147. color: "red"
  148. width: childrenRect.width
  149. height: childrenRect.height
  150. anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter }
  151. Text {
  152. font.pointSize: 40
  153. text: "No images found/provided"
  154. }
  155. }
  156. Rectangle {
  157. z: 1
  158. opacity: 0.5
  159. visible: globalSettings.showViewItemCount
  160. color: "black"
  161. anchors { right: parent.right; top: parent.top }
  162. width: itemCountLabel.width
  163. height: itemCountLabel.height
  164. Text {
  165. id: itemCountLabel
  166. font.pixelSize: 100
  167. text: globalUtil.itemCount
  168. color: "white"
  169. }
  170. }
  171. Rectangle {
  172. z: 1
  173. opacity: 0.5
  174. visible: globalSettings.showScreenResolution
  175. color: "black"
  176. anchors { right: parent.right; top: parent.top }
  177. width: resolutionLabel.width
  178. height: resolutionLabel.height
  179. Text {
  180. id: resolutionLabel
  181. font.pixelSize: 100
  182. text: screenSize.width + "x" + screenSize.height
  183. color: "white"
  184. }
  185. }
  186. Component.onCompleted: {
  187. globalSettings.fullscreen ? showFullScreen() : show()
  188. }
  189. }