756efb99d58b96433db5aede50da0e80ff9ae465
[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: flagLanguage
46         scale: 0.7
47         anchors.left: parent.left
48         anchors.leftMargin: 20
49         anchors.top: parent.top
50         anchors.topMargin: 10
51         source: './images/us_flag.png'
52         visible: true
53     }
54     Image {
55         id: visa
56         width: 200
57         height: 124
58         anchors.right: parent.right
59         anchors.rightMargin: 20
60         anchors.top: parent.top
61         anchors.topMargin: 20
62         source: './images/visa.png'
63         visible: false
64         Label {
65             id: cardNumber
66             anchors.top: parent.bottom
67             anchors.topMargin: 10
68             anchors.horizontalCenter: parent.horizontalCenter
69             horizontalAlignment:  Text.AlignHCenter
70             color: "white"
71             text: "111"
72             font.pixelSize: 20
73             font.family: "Roboto"
74         }
75     }
76     Item {
77         id: hello
78         anchors.horizontalCenter: parent.horizontalCenter
79         anchors.bottom: parent.bottom
80         anchors.bottomMargin: 40
81         visible: true
82         Text {
83             id: helloText
84             anchors.centerIn: parent
85             color: "white"
86             text: "No Authenticated User"
87             font.pixelSize: 40
88             font.family: "Roboto"
89             SequentialAnimation on font.letterSpacing {
90                 id: animation1
91                 loops: 1;
92                 NumberAnimation { from: 0; to: 50; easing.type: Easing.InQuad; duration: 3000 }
93                 onRunningChanged: {
94                     if(running) {
95                         hello.visible = true
96                     } else {
97                         helloText.opacity = 1
98                         helloText.font.letterSpacing = 0
99                     }
100                 }
101             }
102
103             SequentialAnimation on opacity {
104                 id: animation2
105                 loops: 1;
106                 NumberAnimation { from: 1; to: 0; duration: 2600 }
107                 PauseAnimation { duration: 400 }
108             }
109         }
110     }
111     function showHello(helloString) {
112         helloText.text = helloString
113         animation1.running = true;
114         animation2.running = true;
115     }
116
117     function showSign90(show) {
118         sign90.visible = show
119     }
120
121     function showVisa(show, num) {
122         visa.visible = show
123         cardNumber.text = num;
124     }
125     function changeFlag(flagImage) {
126         flagLanguage.source = flagImage
127     }
128
129     GridView {
130         anchors.centerIn: parent
131         width: cellHeight * 3
132         height: cellHeight * 3
133         cellWidth: 320
134         cellHeight: 320
135         interactive: false
136
137         model: ApplicationModel {}
138         delegate: MouseArea {
139             width: 320
140             height: 320
141             Image {
142                 id: appImage
143                 anchors.fill: parent
144                 source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(pressed ? 'Active' : 'Inactive')
145                 Label {
146                     id: labelName
147                     anchors.horizontalCenter: parent.horizontalCenter
148                     horizontalAlignment: Text.AlignHCenter
149                     y: 257
150                     font.pixelSize: 32
151                     font.family: "Roboto"
152                     color: "white"
153                     text: '%1'.arg(model.name)
154                     function myChangeLanguage() {
155                         text = '%1'.arg(model.name)
156                         appImage.source = './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(pressed ? 'Active' : 'Inactive')
157                     }
158                     Component.onCompleted: {
159                         root.languageChanged.connect(myChangeLanguage)
160                     }
161                 }
162             }
163             onClicked: {
164                 console.log("app is ", model.id)
165                 pid = launcher.launch(model.id)
166                 if (1 < pid) {
167                     layoutHandler.makeMeVisible(pid)
168
169                     applicationArea.visible = true
170                     appLauncherAreaLauncher.visible = false
171                     layoutHandler.showAppLayer(pid)
172                 }
173                 else {
174                     console.warn("app cannot be launched!")
175                 }
176             }
177         }
178     }
179 }