SideNavigation.qml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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 HCS
  52. Item {
  53. id:screen
  54. property CLStyle style : StyleHomeControlSystem {}
  55. property int theme : 0
  56. property int iconWidth: 0
  57. property int startPointX: 0
  58. property int startPointY: 0
  59. property int endPointX: 0
  60. property int endPointY: 0
  61. property int controlPointX: 0
  62. property int controlPointY: 0
  63. property bool open: false
  64. property int currentIndex : 0
  65. property real sideBarWidth : 10
  66. property color textColor : style.textColor
  67. signal themeChange()
  68. signal profileChanged()
  69. signal saunaTurnedOff()
  70. /**
  71. * Function opens Side Navigation.
  72. *
  73. * @param openFirst
  74. * @return nothing
  75. */
  76. function openSideNavigation(openFirst) {
  77. open = true
  78. icons.visible = true
  79. var curIndex = icons.currentIndex
  80. if (curIndex <= icons.count){
  81. if (currentIndex == 0 && !openFirst)icons.currentIndex = (icons.currentIndex + Math.round(icons.count/2)) % icons.count
  82. else icons.currentIndex = curIndex
  83. } else {
  84. icons.currentIndex = icons.count -1
  85. }
  86. window.visible=true
  87. sideBar.border.color = style.textColor
  88. }
  89. /**
  90. * Function will close side navigation.
  91. */
  92. function closeSideNavigation() {
  93. open = false
  94. icons.visible=false
  95. window.visible=false
  96. sideBar.border.color = style.bgColor
  97. }
  98. onWidthChanged:{
  99. sideBarWidth = screen.width*0.2
  100. iconWidth = screen.width*0.09
  101. startPointX = iconWidth*1.3
  102. startPointY = Math.round(screen.height*0.16)
  103. endPointX = iconWidth*1.3
  104. endPointY = Math.round(screen.height*0.87)
  105. controlPointX = Math.round(screen.width*0.34)
  106. controlPointY = Math.round(screen.height*0.5)
  107. }
  108. onHeightChanged:{
  109. sideBarWidth = screen.width*0.2
  110. iconWidth = screen.width*0.09
  111. startPointX = iconWidth*1.3
  112. startPointY = Math.round(screen.height*0.16)
  113. endPointX = iconWidth*1.3
  114. endPointY = Math.round(screen.height*0.87)
  115. controlPointX = Math.round(screen.width*0.34)
  116. controlPointY = Math.round(screen.height*0.5)
  117. }
  118. Component.onCompleted:{
  119. sideBarWidth = screen.width*0.2
  120. iconWidth = screen.width*0.09
  121. startPointX = iconWidth*1.3
  122. startPointY = Math.round(screen.height*0.16)
  123. endPointX = iconWidth*1.3
  124. endPointY = Math.round(screen.height*0.87)
  125. controlPointX = Math.round(screen.width*0.34)
  126. controlPointY = Math.round(screen.height*0.5)
  127. open = false
  128. currentIndex = icons.currentIndex
  129. sideBarImage.source = "images/close_button.png"
  130. }
  131. width: 800
  132. height: 424
  133. Rectangle {
  134. id:shadow
  135. anchors.fill: parent
  136. color: style.colorWhenDefault
  137. opacity: (open)?0.7:0
  138. }
  139. Component {
  140. id: delegate
  141. Item{
  142. width:iconWidth
  143. height:iconWidth
  144. Image { smooth:true; width: iconWidth; height: iconWidth; source: icon}
  145. MouseArea{
  146. anchors.fill:parent
  147. onClicked:{
  148. icons.currentIndex = index
  149. window.children[index].opacity = 1
  150. for (var i = 0; i < window.children.length; ++i) {
  151. if (i != index)window.children[i].opacity = 0
  152. }
  153. }
  154. }
  155. }
  156. }
  157. ListModel {
  158. id:iconsModel
  159. ListElement {
  160. title: "Air Conditioning"
  161. icon: "images/ventilator_white_bg_b_100x100.png"
  162. }
  163. ListElement {
  164. title: "Security"
  165. icon: "images/security_white_bg_100x100.png"
  166. }
  167. ListElement {
  168. title: "Energy Consumption"
  169. icon: "images/energy_blue_white_bg_100x100.png"
  170. }
  171. ListElement {
  172. title: "Profiles"
  173. icon: "images/profile_sun_moon_white_bg_100x100.png"
  174. }
  175. ListElement {
  176. title: "Themes"
  177. icon: "images/theme_house_white_bg_100x100.png"
  178. }
  179. ListElement {
  180. title: "Music"
  181. icon: "images/av_player_white_bg_100x100.png"
  182. }
  183. }
  184. PathView {
  185. Image {
  186. id: menuBg
  187. source: "images/menu_bg.png"
  188. height:screen.height
  189. width:screen.controlPointX * 0.85
  190. y: 4
  191. smooth:true
  192. }
  193. id:icons
  194. visible:false
  195. anchors.fill: parent
  196. model: iconsModel
  197. delegate: delegate
  198. preferredHighlightBegin: 0.33
  199. preferredHighlightEnd: 0.33
  200. path: Path {
  201. startX: startPointX; startY: startPointY
  202. PathQuad { x: endPointX; y: endPointY; controlX: controlPointX; controlY: controlPointY }
  203. PathPercent { value: 0.68 }
  204. PathQuad { x: -endPointX; y: endPointY; controlX: 0; controlY: endPointY}
  205. PathQuad { x: -startPointX; y: startPointY/2; controlX: -controlPointX; controlY: controlPointY}
  206. PathQuad { x: startPointX; y: startPointY; controlX: 0; controlY: startPointY/2}
  207. }
  208. onCurrentIndexChanged: {
  209. if (window.children.length == currentIndex){
  210. window.children[0].opacity = 1;
  211. for (var i = 1; i < window.children.length; ++i) {
  212. if (i != currentIndex) {
  213. window.children[i].opacity = 0
  214. } else {
  215. timer.running = true
  216. timer.child = i
  217. window.children[i].opacity = 1
  218. window.children[i].children[1].visible = true
  219. window.children[i].children[2].visible = false
  220. }
  221. }
  222. } else{
  223. for (var i = 0; i < window.children.length; ++i) {
  224. if (i != currentIndex) {
  225. window.children[i].opacity = 0
  226. } else {
  227. timer.running = true
  228. timer.child = i
  229. window.children[i].opacity = 1
  230. window.children[i].children[1].visible = true
  231. window.children[i].children[2].visible = false
  232. }
  233. }
  234. }
  235. }
  236. }
  237. Timer {
  238. id: timer
  239. property int child : 0
  240. running: false
  241. interval: 800
  242. repeat: false
  243. onTriggered: {
  244. window.children[child].children[1].visible = false
  245. window.children[child].children[2].visible = true
  246. }
  247. }
  248. Rectangle{
  249. id: window
  250. width:screen.width-screen.controlPointX * 0.9-5
  251. height: screen.height-10
  252. color: "transparent"
  253. visible: false
  254. anchors.verticalCenter: parent.verticalCenter
  255. x: controlPointX * 0.9
  256. Rectangle{
  257. color:"transparent"
  258. anchors.fill:parent
  259. opacity:0
  260. MouseArea{
  261. anchors.fill:parent
  262. //This mousearea is for disable functionalities under the view
  263. }
  264. Text {
  265. text: iconsModel.get(0).title
  266. font.pointSize: 0.001 + Math.round( 23 * (screen.height / 424) )
  267. anchors.centerIn:parent
  268. color: screen.style.textColor
  269. }
  270. ACView { id: acView; anchors.fill: parent; style: screen.style; onCloseWindow: closeSideNavigation()}
  271. }
  272. Rectangle{
  273. color:"transparent"
  274. anchors.fill:parent
  275. opacity:1
  276. MouseArea{
  277. anchors.fill:parent
  278. //This mousearea is for disable functionalities under the view
  279. }
  280. Text {
  281. text: iconsModel.get(1).title
  282. font.pointSize: 0.001 + Math.round( 23 * (screen.height / 424) )
  283. anchors.centerIn:parent
  284. color: screen.style.textColor
  285. }
  286. Security{ id: securityView; anchors.fill: parent; style: screen.style; onCloseWindow: closeSideNavigation()}
  287. }
  288. Rectangle{
  289. color:"transparent"
  290. anchors.fill:parent
  291. opacity:0
  292. MouseArea{
  293. anchors.fill:parent
  294. //This mousearea is for disable functionalities under the view
  295. }
  296. Text {
  297. text: iconsModel.get(2).title
  298. font.pointSize: 0.001 + Math.round( 23 * (screen.height / 424) )
  299. anchors.centerIn:parent
  300. color: screen.style.textColor
  301. }
  302. EnergyView{ id: energyView; anchors.fill: parent; style: screen.style; onCloseWindow: closeSideNavigation()}
  303. onOpacityChanged: energyView.dummyBool = !energyView.dummyBool;
  304. }
  305. Rectangle{
  306. color:"transparent"
  307. anchors.fill:parent
  308. MouseArea{
  309. anchors.fill:parent
  310. //This mousearea is for disable functionalities under the view
  311. }
  312. Text {
  313. text: iconsModel.get(3).title
  314. font.pointSize: 0.001 + Math.round( 23 * (screen.height / 424) )
  315. anchors.centerIn:parent
  316. color: screen.style.textColor
  317. }
  318. ProfilesView{ id: profilesView; anchors.fill: parent; style: screen.style; onProfileChanged: screen.profileChanged(); onSaunaTurnedOff: screen.profileChanged(); onCloseWindow: closeSideNavigation()}
  319. onOpacityChanged:if(opacity==0){
  320. profilesView.profileToCustom();
  321. }
  322. }
  323. Rectangle{
  324. color:"transparent"
  325. anchors.fill:parent
  326. MouseArea{
  327. anchors.fill:parent
  328. //This mousearea is for disable functionalities under the view
  329. }
  330. Text {
  331. text: iconsModel.get(4).title
  332. font.pointSize: 0.001 + Math.round( 23 * (screen.height / 424) )
  333. anchors.centerIn:parent
  334. color: screen.style.textColor
  335. }
  336. Themes{onThemeChange: screen.themeChange(); anchors.fill: parent; onCloseWindow: closeSideNavigation()}
  337. }
  338. //AV-View
  339. Rectangle{
  340. color:"transparent"
  341. anchors.fill:parent
  342. MouseArea{
  343. anchors.fill:parent
  344. //This mousearea is for disable functionalities under the view
  345. }
  346. Text {
  347. text: iconsModel.get(5).title
  348. font.pointSize: 0.001 + Math.round( 23 * (screen.height / 424) )
  349. anchors.centerIn:parent
  350. color: screen.style.textColor
  351. }
  352. AvView{anchors.fill: parent; style: screen.style; onCloseWindow: closeSideNavigation()}
  353. }
  354. }
  355. Rectangle{
  356. id:sideBar
  357. height:sideBarWidth
  358. width:height
  359. x:-sideBarWidth/1.8//1.7
  360. y:-sideBarWidth/2.3
  361. radius:height/2
  362. color:style.selectionColor
  363. smooth:true
  364. border{width:2;color:style.bgColor}
  365. Image {
  366. id: sideBarImage
  367. x:parent.width/1.8
  368. y:parent.width/2.0
  369. width:parent.width/3
  370. height:parent.width/3
  371. smooth:true
  372. source: (open)?"images/open_button.png":"images/close_button.png"
  373. }
  374. MouseArea{
  375. property bool openFirst : false
  376. anchors.fill:parent
  377. onClicked:{
  378. if (!open) openSideNavigation(openFirst)
  379. else closeSideNavigation()
  380. openFirst = true
  381. }
  382. }
  383. }
  384. onOpenChanged:{
  385. (open)?sideBarImage.source = "images/open_button.png":sideBarImage.source = "images/close_button.png"
  386. }
  387. }