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