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