8753d2948375f8f457786df28b5e09b8d9d74ba3
[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     }
55     Item {
56         id: hello
57         anchors.horizontalCenter: parent.horizontalCenter
58         anchors.bottom: parent.bottom
59         anchors.bottomMargin: 40
60         visible: false
61         Text {
62             id: helloText
63             anchors.centerIn: parent
64             color: "white"
65             text: "Hello José!"
66             font.pixelSize: 40
67             font.family: "Roboto"
68             SequentialAnimation on font.letterSpacing {
69                 id: animation1
70                 loops: 1;
71                 NumberAnimation { from: 0; to: 50; easing.type: Easing.InQuad; duration: 3000 }
72                 onRunningChanged: {
73                     if(running)
74                         hello.visible = true
75                     else
76                         hello.visible = false
77                 }
78             }
79
80             SequentialAnimation on opacity {
81                 id: animation2
82                 loops: 1;
83                 NumberAnimation { from: 1; to: 0; duration: 2600 }
84                 PauseAnimation { duration: 400 }
85             }
86         }
87     }
88     function showHello(helloString) {
89         helloText.text = helloString
90         animation1.running = true;
91         animation2.running = true;
92     }
93
94     function showSign90(show) {
95         sign90.visible = show
96     }
97
98     function showVisa(show) {
99         visa.visible = show
100     }
101     GridView {
102         anchors.centerIn: parent
103         width: cellHeight * 3
104         height: cellHeight * 3
105         cellWidth: 320
106         cellHeight: 320
107         interactive: false
108
109         model: ApplicationModel {}
110         delegate: MouseArea {
111             width: 320
112             height: 320
113             Image {
114                 anchors.fill: parent
115                 source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(pressed ? 'Active' : 'Inactive')
116                 Label {
117                     id: labelName
118                     anchors.horizontalCenter: parent.horizontalCenter
119                     horizontalAlignment: Text.AlignHCenter
120                     y: 257
121                     font.pixelSize: 32
122                     font.family: "Roboto"
123                     color: "white"
124                     text: '%1'.arg(model.name)
125                     function myChangeLanguage() {
126                         text = '%1'.arg(model.name)
127                     }
128                     Component.onCompleted: {
129                         root.languageChanged.connect(myChangeLanguage)
130                     }
131                 }
132             }
133             onClicked: {
134                 console.log("app is ", model.id)
135                 pid = launcher.launch(model.id)
136                 if (1 < pid) {
137                     layoutHandler.makeMeVisible(pid)
138
139                     applicationArea.visible = true
140                     appLauncherAreaLauncher.visible = false
141                     layoutHandler.showAppLayer(pid)
142                 }
143                 else {
144                     console.warn("app cannot be launched!")
145                 }
146             }
147         }
148     }
149 }