3c948dd90f19966f0aeacba59fe033f74874aa72
[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
26     id: root 
27     //width: container.width
28     //height: container.height
29     flags: Qt.FramelessWindowHint
30     visible: true
31
32     Item {
33         id: container
34         anchors.centerIn: parent
35         width: Window.width
36         height: Window.height
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
93                 //if (applicationModel.appid(loc.index) === 'tbtnavi' ||
94                 //    applicationModel.appid(loc.index) === 'hvac') {
95                 //      output_screen = 'Virtual-1'
96                 //}
97                 if (currentId === '') {
98                     homescreenHandler.tapShortcut(applicationModel.appid(loc.index))
99                 } else {
100                     currentId = ''
101                 }
102             }
103             onPositionChanged: {
104                 if (loc.currentId === '') return
105                 if (index < 0) return
106                 if (index === newIndex) return
107                     applicationModel.move(newIndex, newIndex = index)
108             }
109         }
110     }
111 }
112 }