use two sdl app, change default sdl to sdl_usb
[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         state: "normal"
66
67         states: [
68             State {
69                 name: "normal"
70                 PropertyChanges {
71                     target: topArea
72                     y: 0
73                 }
74                 PropertyChanges {
75                     target: applicationArea
76                     y: 218
77                 }
78                 PropertyChanges {
79                     target: mediaArea
80                     y: 1705
81                 }
82             },
83             State {
84                 name: "fullscreen"
85                 PropertyChanges {
86                     target: topArea
87                     y: -220
88                 }
89                 PropertyChanges {
90                     target: applicationArea
91                     y: -1490
92                 }
93                 PropertyChanges {
94                     target: mediaArea
95                     y: 2135
96                 }
97             }
98         ]
99         transitions: Transition {
100             NumberAnimation {
101                 target: topArea
102                 property: "y"
103                 easing.type: "OutQuad"
104                 duration: 250
105             }
106             NumberAnimation {
107                 target: mediaArea
108                 property: "y"
109                 easing.type: "OutQuad"
110                 duration: 250
111             }
112         }
113
114     }
115     Item {
116         id: switchBtn
117         width: 70
118         height: 70
119         anchors.right: parent.right
120         anchors.top: parent.top
121         z: 1
122         property bool enableSwitchBtn: true
123         Image {
124             anchors.right: parent.right
125             anchors.rightMargin: 20
126             anchors.top: parent.top
127             anchors.topMargin: 25
128             width: 35
129             height: 35
130             id: image
131             source: './images/normal.png'
132         }
133
134         MouseArea {
135             anchors.fill: parent
136             onClicked: {
137                 if(switchBtn.enableSwitchBtn) {
138                     var appName = homescreenHandler.getCurrentApplication()
139                     if (container.state === 'normal') {
140                         image.source = './images/fullscreen.png'
141                         container.state = 'fullscreen'
142                         touchArea.switchArea(1)
143                         homescreenHandler.tapShortcut(appName, true)
144                         container.opacity = 0.0
145                     } else {
146                         image.source = './images/normal.png'
147                         container.state = 'normal'
148                         touchArea.switchArea(0)
149                         homescreenHandler.tapShortcut(appName, false)
150                         container.opacity = 1.0
151                     }
152                 }
153             }
154         }
155     }
156     function changeSwitchState(is_navigation) {
157         if(container.state === 'normal') {
158             if(is_navigation) {
159                 switchBtn.enableSwitchBtn = true
160                 image.source = './images/normal.png'
161             } else {
162                 switchBtn.enableSwitchBtn = false
163                 image.source = './images/normal_disable.png'
164             }
165         }
166     }
167 }