main.qml 6.5 KB

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