Floorplan.qml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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 "javascript/sql.js" as HCS
  50. import "../colibri"
  51. import "styles"
  52. Rectangle {
  53. id: mainStructure
  54. property real customScale: 1.00;
  55. property int xpos: 0;
  56. property int ypos: 0;
  57. property real customScale_temp: 1.00;
  58. property int xpos_temp: 0;
  59. property int ypos_temp: 0;
  60. property real customVisibility: 0;
  61. property real textCustomVisibility: 1;
  62. property bool iconHUDReload: true;
  63. property CLStyle style: StyleHomeControlSystem {}
  64. property CLStyle style1: StyleHomeControlSystem {}
  65. property CLStyle style2: StyleHomeControlSystem2 {}
  66. property CLStyle style3: StyleHomeControlSystem3 {}
  67. property CLStyle style4: StyleHomeControlSystem4 {}
  68. property CLStyle style5: StyleHomeControlSystem5 {}
  69. property CLStyle style6: StyleHomeControlSystem6 {}
  70. property bool roomAdjustWindowVisible : false
  71. property int theme : 0
  72. /**
  73. * Sets default values for demonstration
  74. *
  75. * @return Nothing
  76. */
  77. function startupFunction() {
  78. HCS.setDefaults();
  79. }
  80. /**
  81. * Changes HomeControlSystem theme
  82. *
  83. * @return Nothing
  84. */
  85. function changeCLStyle(){
  86. HCS.getTheme();
  87. theme = HCS.theme;
  88. if(theme == 1) style = style1;
  89. else if(theme == 2) style = style2;
  90. else if(theme == 3) style = style3;
  91. else if(theme == 4) style = style4;
  92. else if(theme == 5) style = style5;
  93. else if(theme == 6) style = style6;
  94. }
  95. /**
  96. * Shows overlay window
  97. *
  98. * @param roomToDisplay Unique ID of the room that is being used
  99. * @param roomWidth Room width for scaling purposes
  100. * @param roomHeight Room height for scaling purposes
  101. * @param roomX Room X position for scaling purposes
  102. * @param roomY Room Y position for scaling purposes
  103. * @param roomType Room type (sauna/regular)
  104. * @return Nothing
  105. */
  106. function showWindow (roomToDisplay, roomWidth, roomHeight, roomX, roomY, roomType) {
  107. roomAdjustWindowVisible = true
  108. mainStructure.iconHUDReload = false;
  109. customWindow.room = roomToDisplay;
  110. customScale_temp = 1 * (flickingArea.contentHeight / roomHeight);
  111. xpos_temp = (roomX * customScale_temp) - (flickingArea.width - roomWidth*customScale_temp)/2;
  112. ypos_temp = (roomY * customScale_temp);
  113. if (xpos_temp < 0 ) xpos_temp = 0;
  114. if ((xpos_temp+flickingArea.width) > (flickingArea.contentWidth*customScale_temp)) xpos_temp = (flickingArea.contentWidth * customScale_temp) - flickingArea.width;
  115. customScale = customScale_temp;
  116. xpos = xpos_temp;
  117. ypos = ypos_temp;
  118. customWindowArea.winTarget = roomType;
  119. customVisibility = 1;
  120. textCustomVisibility = 1;
  121. houseRoom1.hideHUD();
  122. houseRoom2.hideHUD();
  123. houseRoom3.hideHUD();
  124. houseRoom4.hideHUD();
  125. houseRoom5.hideHUD();
  126. houseRoom6.hideHUD();
  127. houseRoom7.hideHUD();
  128. houseRoom8.hideHUD();
  129. }
  130. /**
  131. * Hides overlay window
  132. *
  133. * @return Nothing
  134. */
  135. function hideWindow() {
  136. roomAdjustWindowVisible = false
  137. if (customWindowArea.winTarget == "RAW") HCS.saveRoomInfo(customWindow.room, customWindow.temp, customWindow.light, customWindow.volume, customWindow.mute);
  138. mainStructure.iconHUDReload = true;
  139. mainStructure.customScale = 1;
  140. xpos = 0;
  141. ypos = 0;
  142. customVisibility = 0;
  143. textCustomVisibility = 1;
  144. houseRoom1.hideBlur();
  145. houseRoom2.hideBlur();
  146. houseRoom3.hideBlur();
  147. houseRoom4.hideBlur();
  148. houseRoom5.hideBlur();
  149. houseRoom6.hideBlur();
  150. houseRoom7.hideBlur();
  151. houseRoom8.hideBlur();
  152. }
  153. Component.onCompleted: {
  154. startupFunction();
  155. changeCLStyle();
  156. }
  157. width: 800
  158. height: 424
  159. color: style.selectionColor
  160. Behavior on customScale { PropertyAnimation { target: mainStructure; property: "customScale"; duration: 500; easing.type: Easing.InOutQuad; } }
  161. Behavior on xpos { PropertyAnimation { target: mainStructure; property: "xpos"; duration: 500; easing.type: Easing.InOutQuad; } }
  162. Behavior on ypos { PropertyAnimation { target: mainStructure; property: "ypos"; duration: 500; easing.type: Easing.InOutQuad; } }
  163. Behavior on customVisibility { PropertyAnimation { target: mainStructure; property: "customVisibility"; duration: 300; easing.type: Easing.InOutQuad; } }
  164. Behavior on textCustomVisibility { PropertyAnimation { target: mainStructure; property: "textCustomVisibility"; duration: 300; easing.type: Easing.InOutQuad; } }
  165. Rectangle{
  166. anchors.fill:parent
  167. color:style.colorWhenActive
  168. }
  169. Image {
  170. source: "images/floorplan_bg.png"
  171. anchors.fill: parent
  172. smooth: true
  173. }
  174. Flickable {
  175. id: flickingArea
  176. width: parent.width-20
  177. height: parent.height-20
  178. contentWidth: Math.round(width * customScale)
  179. contentHeight: Math.round(height * customScale)
  180. contentX: mainStructure.xpos
  181. contentY: mainStructure.ypos
  182. anchors.verticalCenter: parent.verticalCenter
  183. anchors.horizontalCenter: parent.horizontalCenter
  184. interactive: false
  185. Rectangle {
  186. id: house;
  187. width: flickingArea.contentWidth
  188. height: flickingArea.contentHeight
  189. color: "transparent"
  190. anchors.left: parent.left
  191. anchors.top: parent.top
  192. TheRoom {
  193. id: houseRoom1
  194. style:mainStructure.style
  195. room: "room1"
  196. text: "Bedroom 1"
  197. width: Math.round(house.width * 0.2615)
  198. height: Math.ceil(house.height * (697/1350))
  199. y: Math.floor(house.height * (45/1350))
  200. x: Math.round(house.width * (51/2050))
  201. onClicked: showWindow(theRoomCode, houseRoom1.width, houseRoom1.height, houseRoom1.x, houseRoom1.y, "RAW")
  202. }
  203. TheRoom {
  204. id: houseRoom2
  205. style:mainStructure.style
  206. room: "room2"
  207. text: "Bedroom 2"
  208. height: Math.ceil(house.height * (563/1350))
  209. anchors.top: houseRoom1.bottom
  210. anchors.left: houseRoom1.left
  211. anchors.right: houseRoom1.right
  212. onClicked: showWindow(theRoomCode, houseRoom2.width, houseRoom2.height, houseRoom2.x, houseRoom2.y, "RAW")
  213. }
  214. TheRoom {
  215. id: houseRoom3
  216. style:mainStructure.style
  217. room: "kitchen"
  218. text: "Kitchen"
  219. width: Math.round(house.width * (873/2050))
  220. anchors.top: houseRoom1.top
  221. anchors.left: houseRoom1.right
  222. anchors.bottom: houseRoom1.bottom
  223. onClicked: showWindow(theRoomCode, houseRoom3.width, houseRoom3.height, houseRoom3.x, houseRoom3.y, "RAW")
  224. }
  225. TheRoom {
  226. id: houseRoom8
  227. style:mainStructure.style
  228. room: "livingroom"
  229. text: "Living room"
  230. anchors.top: houseRoom3.bottom
  231. anchors.left: houseRoom1.right
  232. anchors.bottom: houseRoom2.bottom
  233. anchors.right: houseRoom3.right
  234. onClicked: showWindow(theRoomCode, houseRoom8.width, houseRoom8.height, houseRoom8.x, houseRoom8.y, "RAW")
  235. }
  236. TheRoom {
  237. id: houseRoom4
  238. style:mainStructure.style
  239. room: "room3"
  240. text: "Master bedroom"
  241. width: Math.round(house.width * (541/2050))
  242. anchors.top: houseRoom1.bottom
  243. anchors.bottom: houseRoom2.bottom
  244. anchors.left: houseRoom3.right
  245. onClicked: showWindow(theRoomCode, houseRoom4.width, houseRoom4.height, houseRoom4.x, houseRoom4.y, "RAW")
  246. }
  247. TheRoom {
  248. id: houseRoom5
  249. style:mainStructure.style
  250. room: "khh"
  251. text: "Utility room"
  252. height: Math.round(house.height * (289/1350))
  253. anchors.top: houseRoom1.top
  254. anchors.left: houseRoom3.right
  255. anchors.right: houseRoom4.right
  256. onClicked: showWindow(theRoomCode, houseRoom5.width, houseRoom5.height, houseRoom5.x, houseRoom5.y, "RAW")
  257. }
  258. TheRoom {
  259. id: houseRoom6
  260. style:mainStructure.style
  261. room: "sauna"
  262. text: "Sauna"
  263. width: Math.round(house.width * (287/2050))
  264. anchors.top: houseRoom5.bottom
  265. anchors.left: houseRoom3.right
  266. anchors.bottom: houseRoom4.top
  267. onClicked: showWindow(theRoomCode, houseRoom6.width, houseRoom6.height, houseRoom6.x, houseRoom6.y, "SAUNA")
  268. }
  269. TheRoom {
  270. id: houseRoom7
  271. style:mainStructure.style
  272. room: "kph"
  273. text: "Bath"
  274. anchors.top: houseRoom5.bottom
  275. anchors.left: houseRoom6.right
  276. anchors.bottom: houseRoom4.top
  277. anchors.right: houseRoom5.right
  278. onClicked: showWindow(theRoomCode, houseRoom7.width, houseRoom7.height, houseRoom7.x, houseRoom7.y, "RAW")
  279. }
  280. }
  281. Image {
  282. id: bottomImg
  283. source: "images/floorplan.png"
  284. width: house.width
  285. height: house.height
  286. opacity: 1
  287. }
  288. LockHUD {
  289. anchors.bottom: bottomImg.bottom
  290. anchors.horizontalCenter: bottomImg.horizontalCenter
  291. anchors.bottomMargin: -5 * (flickingArea.height / 404)
  292. iconSize: 44 * (flickingArea.height / 404)
  293. doReload: mainStructure.iconHUDReload;
  294. opacity: textCustomVisibility
  295. }
  296. }
  297. Rectangle {
  298. id: customWindowArea
  299. property string winTarget: "SAUNA"
  300. color: "transparent"
  301. anchors.fill: parent
  302. visible: (mainStructure.customVisibility==0)?false:true;
  303. MouseArea {
  304. anchors.fill: parent
  305. onClicked: hideWindow()
  306. }
  307. RoomAdjustWidget {
  308. id: customWindow;
  309. style: mainStructure.style
  310. anchors.centerIn: parent;
  311. width: parent.width-120;
  312. height: parent.height-60;
  313. opacity: mainStructure.customVisibility
  314. anchors.verticalCenter: parent.verticalCenter
  315. anchors.horizontalCenter: parent.horizontalCenter
  316. visible: (customWindowArea.winTarget=="RAW")?true:false
  317. onCloseWindow: hideWindow()
  318. }
  319. SaunaView{
  320. visible: (customWindowArea.winTarget=="SAUNA")?true:false
  321. style: mainStructure.style;
  322. width: parent.width*0.9;
  323. height: parent.height*0.9;
  324. anchors.centerIn: parent
  325. onCloseWindow: hideWindow()
  326. }
  327. }
  328. SideNavigation{id:sidenavigation; anchors.fill:parent; onThemeChange: mainStructure.changeCLStyle(); style: mainStructure.style; onProfileChanged: {customWindow.updateInfo();} }
  329. }