agl-compositor: New adaptation to using the agl-shell-desktop proto
[apps/launcher.git] / launcher / qml / Launcher.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
4  * Copyright (c) 2018,2019 TOYOTA MOTOR CORPORATION
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 import QtQuick 2.6
19 import QtQuick.Layouts 1.1
20 import QtQuick.Controls 2.0
21 import QtQuick.Window 2.13
22 import AppModel 1.0
23
24 ApplicationWindow {
25     width: container.width * container.scale
26     height: container.height * container.scale
27
28     property int pid: -1
29
30     Item {
31         id: container
32         anchors.centerIn: parent
33         width: Screen.width
34         height: Screen.height
35         //scale: screenInfo.scale_factor()
36         scale: 1
37
38         Image {
39           anchors.centerIn: parent
40           source: './images/AGL_HMI_Blue_Background_Car-01.png'
41         }
42
43     GridView {
44         id: grid
45         anchors {
46           topMargin: 60; bottomMargin: 0 
47           leftMargin: 60; rightMargin: 60
48           fill: parent
49         }
50         contentHeight: 320
51         flickableDirection: Flickable.AutoFlickDirection
52         snapMode: GridView.SnapOneRow
53         visible: true
54         cellWidth: 320
55         cellHeight: 320
56         interactive: false
57
58         model: ApplicationModel { id: applicationModel }
59         delegate: IconItem {
60             width: grid.cellWidth
61             height: grid.cellHeight
62         }
63
64         Connections {
65             target: homescreenHandler
66             onAppListUpdate: {
67                 console.warn("applist update in Launcher.qml")
68                 applicationModel.updateApplist(info);
69             }
70         }
71         Connections {
72             target: homescreenHandler
73             onInitAppList: {
74                 console.warn("applist init in Launcher.qml")
75                 applicationModel.initAppList(data);
76             }
77         }
78
79         MouseArea {
80             id: loc
81             anchors.fill: parent
82             property string currentId: ''
83             property int newIndex: -1
84             property int index: grid.indexAt(loc.mouseX, loc.mouseY)
85             x: 62
86             y: 264
87             onPressAndHold: currentId = applicationModel.id(newIndex = index)
88             onReleased: {
89                 if(loc.index < 0) {
90                     return
91                 }
92                 if (currentId === '') {
93                     homescreenHandler.tapShortcut(applicationModel.appid(loc.index))
94                 } else {
95                     currentId = ''
96                 }
97             }
98             onPositionChanged: {
99                 if (loc.currentId === '') return
100                 if (index < 0) return
101                 if (index === newIndex) return
102                     applicationModel.move(newIndex, newIndex = index)
103             }
104         }
105     }
106 }
107 }