change fullscreen button size.
[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: 1920
35         height: 720
36         scale: 1.0
37         source: './images/menubar_background.png'
38
39         ColumnLayout {
40             id: menuBar
41             anchors.fill: parent
42             spacing: 0
43             TopArea {
44                 id: topArea
45                 anchors.horizontalCenter: parent.horizontalCenter
46                 Layout.preferredHeight: 80
47                 x: 640
48             }
49
50             Item {
51                 id: applicationArea
52                 Layout.fillWidth: true
53                 Layout.fillHeight: true
54                 Layout.preferredHeight: 510
55
56                 visible: true
57                 MouseArea {
58                     enabled: true
59                 }
60             }
61
62             ShortcutArea {
63                 id: shortcutArea
64                 anchors.horizontalCenter: parent.horizontalCenter
65                 Layout.fillHeight: true
66                 Layout.preferredHeight: 130
67             }
68         }
69         states: [
70             State {
71                 name: "normal"
72                 PropertyChanges {
73                     target: container
74                     y: 0
75                 }
76                 PropertyChanges {
77                     target: topArea
78                     y: 0
79                 }
80                 PropertyChanges {
81                     target: applicationArea
82                     y: 80
83                 }
84                 PropertyChanges {
85                     target: shortcutArea
86                     y: 590
87                 }
88             },
89             State {
90                 name: "fullscreen"
91                 PropertyChanges {
92                     target: container
93                     y: -720
94                 }
95                 PropertyChanges {
96                     target: topArea
97                     y: -80
98                 }
99                 PropertyChanges {
100                     target: applicationArea
101                     y: -510
102                 }
103                 PropertyChanges {
104                     target: shortcutArea
105                     y: 720
106                 }
107             }
108         ]
109         transitions: Transition {
110             NumberAnimation {
111                 target: topArea
112                 property: "y"
113                 easing.type: "OutQuad"
114                 duration: 250
115             }
116             NumberAnimation {
117                 target: applicationArea
118                 property: "y"
119                 easing.type: "OutQuad"
120                 duration: 250
121             }
122             NumberAnimation {
123                 target: shortcutArea
124                 property: "y"
125                 easing.type: "OutQuad"
126                 duration: 250
127             }
128         }
129     }
130
131
132
133
134
135     Item {
136         id: switchBtn
137         width: 110
138         height: 110
139         anchors.right: parent.right
140         anchors.top: parent.top
141         z: 1
142         Image {
143             id: image
144             width: 55
145             height: 55
146             anchors.right: parent.right
147             anchors.rightMargin: 20
148             anchors.top: parent.top
149             anchors.topMargin: 5
150             source: './images/normal.png'
151         }
152
153         MouseArea {
154             anchors.fill: parent
155             property string btnState: 'normal'
156             onClicked: {
157                 if (container.state === 'normal') {
158                     turnToFullscreen()
159                 } else {
160                     turnToNormal()
161                 }
162             }
163         }
164     }
165     function turnToFullscreen() {
166         image.source = './images/fullscreen.png'
167         container.state = 'fullscreen'
168         container.opacity = 0.0
169         touchArea.switchArea(1)
170     }
171     function turnToNormal() {
172         image.source = './images/normal.png'
173         container.state = 'normal'
174         container.opacity = 1.0
175         touchArea.switchArea(0)
176     }
177 }