Home screen translation changes
[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
94         model: ApplicationModel {}
95         delegate: MouseArea {
96             width: 320
97             height: 320
98             Image {
99                 anchors.fill: parent
100                 source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(pressed ? 'Active' : 'Inactive')
101                 Label {
102                     id: labelName
103                     anchors.horizontalCenter: parent.horizontalCenter
104                     horizontalAlignment: Text.AlignHCenter
105                     y: 257
106                     font.pixelSize: 32
107                     font.family: "Roboto"
108                     color: "white"
109                     text: '%1'.arg(model.name)
110                     function myChangeLanguage() {
111                         text = '%1'.arg(model.name)
112                     }
113                     Component.onCompleted: {
114                         root.languageChanged.connect(myChangeLanguage)
115                     }
116                 }
117             }
118             onClicked: {
119                 console.log("app is ", model.id)
120                 pid = launcher.launch(model.id)
121                 if (1 < pid) {
122                     layoutHandler.makeMeVisible(pid)
123
124                     applicationArea.visible = true
125                     appLauncherAreaLauncher.visible = false
126                     layoutHandler.showAppLayer(pid)
127                 }
128                 else {
129                     console.warn("app cannot be launched!")
130                 }
131             }
132         }
133     }
134 }