websockets mechanism implemented
[staging/HomeScreen.git] / HomeScreen / qml / Home.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 import QtQuick 2.2
19 import QtQuick.Layouts 1.1
20 import QtQuick.Controls 1.0
21 import Home 1.0
22
23 Item {
24     id: root
25     property int pid: -1
26     signal languageChanged
27
28     Image {
29         anchors.fill: parent
30         anchors.topMargin: -218
31         anchors.bottomMargin: -215
32         source: './images/AGL_HMI_Background_Car-01.png'
33     }
34     Image {
35         id: sign90
36         width: 200
37         height: 200
38         anchors.horizontalCenter: parent.horizontalCenter
39         anchors.top: parent.top
40         anchors.topMargin: 20
41         source: './images/B14-90.png'
42         visible: false
43     }
44     Image {
45         id: visa
46         width: 200
47         height: 124
48         anchors.right: parent.right
49         anchors.rightMargin: 20
50         anchors.top: parent.top
51         anchors.topMargin: 20
52         source: './images/visa.png'
53         visible: false
54         Label {
55             id: cardNumber
56             anchors.top: parent.bottom
57             anchors.topMargin: 10
58             anchors.horizontalCenter: parent.horizontalCenter
59             horizontalAlignment:  Text.AlignHCenter
60             color: "white"
61             text: "111"
62             font.pixelSize: 20
63             font.family: "Roboto"
64         }
65     }
66     Item {
67         id: hello
68         anchors.horizontalCenter: parent.horizontalCenter
69         anchors.bottom: parent.bottom
70         anchors.bottomMargin: 40
71         visible: false
72         Text {
73             id: helloText
74             anchors.centerIn: parent
75             color: "white"
76             text: ""
77             font.pixelSize: 40
78             font.family: "Roboto"
79             SequentialAnimation on font.letterSpacing {
80                 id: animation1
81                 loops: 1;
82                 NumberAnimation { from: 0; to: 50; easing.type: Easing.InQuad; duration: 3000 }
83                 onRunningChanged: {
84                     if(running)
85                         hello.visible = true
86                     else
87                         hello.visible = false
88                 }
89             }
90
91             SequentialAnimation on opacity {
92                 id: animation2
93                 loops: 1;
94                 NumberAnimation { from: 1; to: 0; duration: 2600 }
95                 PauseAnimation { duration: 400 }
96             }
97         }
98     }
99     function showHello(helloString) {
100         helloText.text = helloString
101         animation1.running = true;
102         animation2.running = true;
103     }
104
105     function showSign90(show) {
106         sign90.visible = show
107     }
108
109     function showVisa(show, num) {
110         visa.visible = show
111         cardNumber.text = num;
112     }
113     GridView {
114         anchors.centerIn: parent
115         width: cellHeight * 3
116         height: cellHeight * 3
117         cellWidth: 320
118         cellHeight: 320
119
120         model: ApplicationModel {}
121         delegate: MouseArea {
122             width: 320
123             height: 320
124             Image {
125                 anchors.fill: parent
126                 source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(pressed ? 'Active' : 'Inactive')
127                 Label {
128                     id: labelName
129                     anchors.horizontalCenter: parent.horizontalCenter
130                     horizontalAlignment: Text.AlignHCenter
131                     y: 257
132                     font.pixelSize: 32
133                     font.family: "Roboto"
134                     color: "white"
135                     text: '%1'.arg(model.name)
136                     function myChangeLanguage() {
137                         text = '%1'.arg(model.name)
138                     }
139                     Component.onCompleted: {
140                         root.languageChanged.connect(myChangeLanguage)
141                     }
142                 }
143             }
144             onClicked: {
145                 console.log("app is ", model.id)
146                 pid = launcher.launch(model.id)
147                 if (1 < pid) {
148                     layoutHandler.makeMeVisible(pid)
149
150                     applicationArea.visible = true
151                     appLauncherAreaLauncher.visible = false
152                     layoutHandler.showAppLayer(pid)
153                 }
154                 else {
155                     console.warn("app cannot be launched!")
156                 }
157             }
158         }
159     }
160 }