c218057337dfbb0c028b7ee236208475319970f4
[apps/homescreen.git] / homescreen / qml / main.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  * Copyright (C) 2016, 2017 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.Window 2.1
20 import QtQuick.Layouts 1.1
21 import HomeScreen 1.0
22
23 Window {
24     visible: true
25     flags: Qt.FramelessWindowHint
26     width: container.width * container.scale
27     height: container.height * container.scale
28     title: 'HomeScreen'
29     color: "#00000000"
30
31     Image {
32         id: container
33         anchors.centerIn: parent
34         width: 1080
35         height: 1920
36         scale: 1.0
37         source: './images/AGL_HMI_Blue_Background_NoCar-01.png'
38
39         ColumnLayout {
40             anchors.fill: parent
41             spacing: 0
42             TopArea {
43                 id: topArea
44                 Layout.fillWidth: true
45                 Layout.preferredHeight: 218
46             }
47
48             Item {
49                 id: applicationArea
50                 Layout.fillWidth: true
51                 Layout.fillHeight: true
52                 Layout.preferredHeight: 1920 - 218 - 215
53
54                 visible: true
55             }
56
57             MediaArea {
58                 id: mediaArea
59                 Layout.fillWidth: true
60                 Layout.fillHeight: true
61                 Layout.preferredHeight: 215
62             }
63         }
64
65         states: [
66             State {
67                 name: "normal"
68                 PropertyChanges {
69                     target: topArea
70                     y: 0
71                 }
72                 PropertyChanges {
73                     target: applicationArea
74                     y: 218
75                 }
76                 PropertyChanges {
77                     target: mediaArea
78                     y: 1705
79                 }
80             },
81             State {
82                 name: "fullscreen"
83                 PropertyChanges {
84                     target: topArea
85                     y: -220
86                 }
87                 PropertyChanges {
88                     target: applicationArea
89                     y: -1490
90                 }
91                 PropertyChanges {
92                     target: mediaArea
93                     y: 2135
94                 }
95             }
96         ]
97         transitions: Transition {
98             NumberAnimation {
99                 target: topArea
100                 property: "y"
101                 easing.type: "OutQuad"
102                 duration: 250
103             }
104             NumberAnimation {
105                 target: mediaArea
106                 property: "y"
107                 easing.type: "OutQuad"
108                 duration: 250
109             }
110         }
111
112     }
113     Item {
114         id: switchBtn
115         anchors.right: parent.right
116         anchors.rightMargin: 20
117         anchors.top: parent.top
118         anchors.topMargin: 25
119         width: 35
120         height: 35
121         z: 1
122
123         MouseArea {
124             anchors.fill: parent
125             property string btnState: 'normal'
126             Image {
127                 id: image
128                 anchors.fill: parent
129                 source: './images/normal.png'
130             }
131             onClicked: {
132                 var appName = homescreenHandler.getCurrentApplication()
133                 if (btnState === 'normal') {
134                     image.source = './images/fullscreen.png'
135                     btnState = 'fullscreen'
136                     container.state = 'fullscreen'
137                     touchArea.switchArea(1)
138                     homescreenHandler.tapShortcut(appName, true)
139                     if (appName === 'navigation' || appName === 'browser') {
140                         container.opacity = 0.0
141                     }
142                 } else {
143                     image.source = './images/normal.png'
144                     btnState = 'normal'
145                     container.state = 'normal'
146                     touchArea.switchArea(0)
147                     homescreenHandler.tapShortcut(appName, false)
148                     if (appName === 'navigation' || appName === 'browser') {
149                         container.opacity = 1.0
150                     }
151                 }
152             }
153         }
154     }
155 }