change size to 1920x1080
[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: fullscreen_back
33         anchors.centerIn: parent
34         width: 1920
35         height: 1080
36         source: './images/menubar_fullscreen_background.png'
37     }
38
39     Image {
40         id: container
41         anchors.centerIn: parent
42         width: 1920
43         height: 1080
44         scale: 1.0
45         source: './images/menubar_background.png'
46
47         ColumnLayout {
48             id: menuBar
49             width: 1920
50             height: 720
51 //            y:180
52             spacing: 0
53             TopArea {
54                 id: topArea
55                 anchors.horizontalCenter: parent.horizontalCenter
56                 Layout.preferredHeight: 80
57                 x: 640
58             }
59
60             Item {
61                 id: applicationArea
62                 Layout.fillWidth: true
63                 Layout.fillHeight: true
64                 Layout.preferredHeight: 510
65
66                 visible: true
67                 MouseArea {
68                     enabled: true
69                 }
70             }
71
72             ShortcutArea {
73                 id: shortcutArea
74                 anchors.horizontalCenter: parent.horizontalCenter
75                 Layout.fillHeight: true
76                 Layout.preferredHeight: 130
77             }
78         }
79         states: [
80             State {
81                 name: "normal"
82                 PropertyChanges {
83                     target: container
84                     y: 180
85                 }
86                 PropertyChanges {
87                     target: topArea
88                     y: 180
89                 }
90                 PropertyChanges {
91                     target: applicationArea
92                     y: 260
93                 }
94                 PropertyChanges {
95                     target: shortcutArea
96                     y: 770
97                 }
98             },
99             State {
100                 name: "fullscreen"
101                 PropertyChanges {
102                     target: container
103                     y: -900
104                 }
105                 PropertyChanges {
106                     target: topArea
107                     y: -260
108                 }
109                 PropertyChanges {
110                     target: applicationArea
111                     y: -590
112                 }
113                 PropertyChanges {
114                     target: shortcutArea
115                     y: 900
116                 }
117             }
118         ]
119         transitions: Transition {
120             NumberAnimation {
121                 target: topArea
122                 property: "y"
123                 easing.type: "OutQuad"
124                 duration: 250
125             }
126             NumberAnimation {
127                 target: applicationArea
128                 property: "y"
129                 easing.type: "OutQuad"
130                 duration: 250
131             }
132             NumberAnimation {
133                 target: shortcutArea
134                 property: "y"
135                 easing.type: "OutQuad"
136                 duration: 250
137             }
138         }
139     }
140
141     Item {
142         id: switchBtn
143         width: 61
144         height: 61
145         anchors.right: parent.right
146         anchors.rightMargin: 17
147         anchors.top: parent.top
148         anchors.topMargin: 182
149         z: 1
150         Image {
151             id: image
152             width: 55
153             height: 55
154             anchors.centerIn: parent
155             source: './images/normal.png'
156         }
157
158         MouseArea {
159             anchors.fill: parent
160             property string btnState: 'normal'
161             onClicked: {
162                 if (container.state === 'normal') {
163                     turnToFullscreen()
164                 } else {
165                     turnToNormal()
166                 }
167             }
168         }
169     }
170
171     Item {
172         id: splitSwitchBtn
173         width: 61
174         height: 61
175         anchors.right: switchBtn.left
176         anchors.top: parent.top
177         anchors.topMargin: 182
178         z: 1
179         property bool enableSplitSwitchBtn: false
180         Image {
181             id: splitSwitchImage
182             width: 55
183             height: 55
184             anchors.centerIn: parent
185             source: './images/split_switch_disable.png'
186         }
187
188         MouseArea {
189             property bool changed : false
190             anchors.fill: parent
191             onClicked: {
192                 if (splitSwitchBtn.enableSplitSwitchBtn) {
193                     if(changed) {
194                         switchSplitArea(0)
195                         changed = false
196                     }
197                     else {
198                         switchSplitArea(1)
199                         changed = true
200                     }
201                 }
202             }
203         }
204     }
205
206
207     function turnToFullscreen() {
208         image.source = './images/fullscreen.png'
209         container.state = 'fullscreen'
210         container.opacity = 0.0
211         touchArea.switchArea(1)
212     }
213
214     function turnToNormal() {
215         image.source = './images/normal.png'
216         container.state = 'normal'
217         container.opacity = 1.0
218         touchArea.switchArea(0)
219     }
220
221     function enableSplitSwitchBtn() {
222         splitSwitchImage.source = './images/split_switch.png'
223         splitSwitchBtn.enableSplitSwitchBtn = true
224     }
225
226     function disableSplitSwitchBtn() {
227         splitSwitchImage.source = './images/split_switch_disable.png'
228         splitSwitchBtn.enableSplitSwitchBtn = false;
229     }
230
231     function switchSplitArea(val) {
232         homescreenHandler.changeLayout(val);
233     }
234 }