horizontal
[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         anchors.right: parent.right
138         anchors.rightMargin: 20
139         anchors.top: parent.top
140         anchors.topMargin: 5
141         width: 55
142         height: 55
143         z: 1
144
145         MouseArea {
146             anchors.fill: parent
147             property string btnState: 'normal'
148             Image {
149                 id: image
150                 anchors.fill: parent
151                 source: './images/normal.png'
152             }
153             onClicked: {
154                 if (btnState === 'normal') {
155                     image.source = './images/fullscreen.png'
156                     btnState = 'fullscreen'
157                     container.state = 'fullscreen'
158                     container.opacity = 0.0
159                     touchArea.switchArea(1)
160
161                 } else {
162                     image.source = './images/normal.png'
163                     btnState = 'normal'
164                     container.state = 'normal'
165                     container.opacity = 1.0
166                     touchArea.switchArea(0)
167                 }
168             }
169         }
170     }
171 }