Security.qml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /**
  2. * Copyright © 2010 Digia Plc
  3. * Copyright © 2010 Nokia Corporation
  4. *
  5. * All rights reserved.
  6. *
  7. * Nokia and Nokia Connecting People are registered trademarks of
  8. * Nokia Corporation.
  9. * Java and all Java-based marks are trademarks or registered
  10. * trademarks of
  11. * Sun Microsystems, Inc. Other product and company names
  12. * mentioned herein may be
  13. * trademarks or trade names of their respective owners.
  14. *
  15. *
  16. * Subject to the conditions below, you may, without charge:
  17. *
  18. * · Use, copy, modify and/or merge copies of this software and
  19. * associated documentation files (the "Software")
  20. *
  21. * · Publish, distribute, sub-licence and/or sell new software
  22. * derived from or incorporating the Software.
  23. *
  24. *
  25. * This file, unmodified, shall be included with all copies or
  26. * substantial portions
  27. * of the Software that are distributed in source code form.
  28. *
  29. * The Software cannot constitute the primary value of any new
  30. * software derived
  31. * from or incorporating the Software.
  32. *
  33. * Any person dealing with the Software shall not misrepresent
  34. * the source of the Software.
  35. *
  36. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  37. * KIND, EXPRESS OR IMPLIED,
  38. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39. * MERCHANTABILITY, FITNESS FOR A
  40. * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41. * AUTHORS OR COPYRIGHT
  42. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  43. * WHETHER IN AN ACTION
  44. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  45. * CONNECTION WITH THE
  46. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  47. */
  48. import Qt 4.7
  49. import "../colibri"
  50. import "styles"
  51. import "javascript/sql.js" as DB
  52. Rectangle {
  53. id: window
  54. property real camWidth : window.width*0.3
  55. property real camHeight : window.height*0.3
  56. property real scaleHeight : window.height/424
  57. property real scaleWidth : window.width/640
  58. property real scaleOverall : Math.min(scaleHeight,scaleWidth);
  59. property real scale : 0.25 * scaleOverall
  60. property real scaleValueBig : 2.5
  61. property CLStyle style : StyleHomeControlSystem {}
  62. property int selectedCam: -1
  63. property int lastZ: 5
  64. signal closeWindow()
  65. /**
  66. * Scales camera picture
  67. *
  68. * @param index The index of the camera
  69. * @return Nothing
  70. */
  71. function scaleCam(index) {
  72. if( index >= 0 ) {
  73. if( window.selectedCam == index ) {
  74. camGrid.children[index].width = Math.round(camGrid.width*0.48);
  75. camGrid.children[index].height = Math.round(camGrid.height*0.48);
  76. window.selectedCam = -1;
  77. } else {
  78. window.selectedCam = index;
  79. camGrid.children[index].z = window.lastZ + 1;
  80. camGrid.children[index].width = Math.round(camGrid.width*1);
  81. camGrid.children[index].height = Math.round(camGrid.height*1);
  82. window.lastZ = window.lastZ + 1;
  83. }
  84. }
  85. }
  86. /**
  87. * Sets alarm On/Off
  88. *
  89. * @return Nothing
  90. */
  91. function alarmClicked() {
  92. if(alarm.checked) {
  93. DB.setAlarmSystemOn(true);
  94. } else {
  95. DB.setAlarmSystemOn(false);
  96. }
  97. }
  98. width: 640
  99. height: 420
  100. color: "transparent"
  101. Timer {
  102. interval: 1000; running: true; repeat: true
  103. onTriggered: {
  104. if(DB.isAlarmSystemOn()) alarm.checked = true;
  105. else alarm.checked = false;
  106. }
  107. }
  108. Rectangle{
  109. width:window.width*0.955
  110. height:window.height*0.924
  111. color:style.selectionColor
  112. anchors.centerIn:parent
  113. radius:7
  114. }
  115. Image {
  116. source: "images/control_bg_trans_420x275_png.png";
  117. anchors.fill: parent;
  118. smooth: true
  119. opacity:0.7
  120. }
  121. RoomExitButton {
  122. windowWidth: window.width
  123. windowHeight: window.height
  124. style: window.style
  125. onClicked: window.closeWindow();
  126. }
  127. Text {
  128. id: textSecurity
  129. text: "Security"
  130. font.pixelSize: 1 + Math.round( 23 * (window.height / 424) )
  131. x: Math.round( window.width * 0.05 )
  132. y: Math.round( window.height * 0.05 )
  133. color: window.style.textColor
  134. font.bold: true
  135. }
  136. Row {
  137. y: window.height*0.045
  138. anchors.right: parent.right
  139. anchors.rightMargin: window.width*0.12
  140. Row {
  141. Text {text: "Alarm System: "; font.pointSize: 0.001 + window.height*0.036; anchors.verticalCenter: parent.verticalCenter; color: window.style.textColor}
  142. CLCheckBox{id: alarm; checkMark: "On"; style:window.style; height: window.height*0.14; width: height; fontSize: window.height*0.06; onClicked: alarmClicked()}
  143. }
  144. }
  145. Rectangle {
  146. id: camGrid
  147. height: window.height*0.75
  148. width: window.width*0.75
  149. anchors.horizontalCenter: parent.horizontalCenter;
  150. y: window.height*0.20
  151. color: "transparent"
  152. Rectangle {
  153. border.color: style.textColor
  154. border.width: 2
  155. width: (selectedCam==0)?camGrid.width : camGrid.width*0.48; height: (selectedCam==0)? camGrid.height : camGrid.height*0.48
  156. anchors.left: camGrid.left; anchors.top: camGrid.top; z: (width!=camGrid.width*0.48)? 6 : 5
  157. Image {
  158. id: img1
  159. source:"images/camera1.jpg"
  160. width: parent.width - parent.border.width; height: parent.height - parent.border.width
  161. x: parent.border.width/2; y: parent.border.width/2
  162. }
  163. MouseArea {
  164. anchors.fill: parent
  165. onClicked: {
  166. if(selectedCam == 0) {
  167. selectedCam = -1;
  168. } else if(selectedCam == -1) {
  169. selectedCam = 0;
  170. }
  171. }
  172. }
  173. Behavior on width { PropertyAnimation { duration: 100; } }
  174. Behavior on height { PropertyAnimation { duration: 100; } }
  175. }
  176. Rectangle {
  177. border.color: style.textColor
  178. border.width: 2
  179. width: (selectedCam==1)?camGrid.width : camGrid.width*0.48; height: (selectedCam==1)? camGrid.height : camGrid.height*0.48
  180. anchors.right: camGrid.right; anchors.top: camGrid.top; z: (width!=camGrid.width*0.48)? 6 : 5
  181. Image {
  182. id: img2
  183. source:"images/camera2.jpg"
  184. width: parent.width - parent.border.width; height: parent.height - parent.border.width
  185. x: parent.border.width/2; y: parent.border.width/2
  186. }
  187. MouseArea {
  188. anchors.fill: parent
  189. onClicked: {
  190. if(selectedCam == 1) {
  191. selectedCam = -1;
  192. } else if(selectedCam == -1) {
  193. selectedCam = 1;
  194. }
  195. }
  196. }
  197. Behavior on width { PropertyAnimation { duration: 100; } }
  198. Behavior on height { PropertyAnimation { duration: 100; } }
  199. }
  200. Rectangle {
  201. border.color: style.textColor
  202. border.width: 2
  203. width: (selectedCam==2)? camGrid.width : camGrid.width*0.48; height: (selectedCam==2)? camGrid.height : camGrid.height*0.48
  204. anchors.left: camGrid.left; anchors.bottom: camGrid.bottom; z: (width!=camGrid.width*0.48)? 6 : 5
  205. Image {
  206. id: img3
  207. source:"images/camera4.jpg"
  208. width: parent.width - parent.border.width; height: parent.height - parent.border.width
  209. x: parent.border.width/2; y: parent.border.width/2
  210. }
  211. MouseArea {
  212. anchors.fill: parent
  213. onClicked: {
  214. if(selectedCam == 2) {
  215. selectedCam = -1;
  216. } else if(selectedCam == -1) {
  217. selectedCam = 2;
  218. }
  219. }
  220. }
  221. Behavior on width { PropertyAnimation { duration: 100; } }
  222. Behavior on height { PropertyAnimation { duration: 100; } }
  223. }
  224. Rectangle {
  225. border.color: style.textColor
  226. border.width: 2
  227. width: (selectedCam==3)? camGrid.width : camGrid.width*0.48; height: (selectedCam==3)? camGrid.height : camGrid.height*0.48
  228. anchors.right: camGrid.right; anchors.bottom: camGrid.bottom; z: (width!=camGrid.width*0.48)? 6 : 5
  229. Image {
  230. id: img4
  231. source:"images/camera3.jpg"
  232. width: parent.width - parent.border.width; height: parent.height - parent.border.width
  233. x: parent.border.width/2; y: parent.border.width/2
  234. }
  235. MouseArea {
  236. anchors.fill: parent
  237. onClicked: {
  238. if(selectedCam == 3) {
  239. selectedCam = -1;
  240. } else if(selectedCam == -1) {
  241. selectedCam = 3;
  242. }
  243. }
  244. }
  245. Behavior on width { PropertyAnimation { duration: 100; } }
  246. Behavior on height { PropertyAnimation { duration: 100; } }
  247. }
  248. }
  249. }