894ff9874c768d16c68bf89eb1287421954d9680
[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.13
19 import QtQuick.Layouts 1.1
20 import QtQuick.Controls 2.0
21 import QtQuick.Window 2.13
22 import QtGraphicalEffects 1.0
23 import AppModel 1.0
24
25 ApplicationWindow {
26
27     id: root
28     //width: container.width
29     //height: container.height
30     flags: Qt.FramelessWindowHint
31     visible: true
32
33     Item {
34         id: container
35         anchors.centerIn: parent
36         width: Window.width
37         height: Window.height
38
39         Image {
40             anchors.centerIn: parent
41             source: './images/AGL_HMI_Blue_Background_Car-01.png'
42         }
43
44         GridView {
45             id: grid
46             anchors {
47                 topMargin: 60; bottomMargin: 60
48                 leftMargin: 60; rightMargin: 60
49                 fill: parent
50             }
51             contentHeight: 320
52             // change this HorizontalFlick or see Flickable documentation
53             // for other possible combinations
54             flickableDirection: Flickable.VerticalFlick
55             snapMode: GridView.SnapOneRow
56             visible: true
57             cellWidth: 320
58             cellHeight: 320
59             interactive: apps_len > 12 ? true : false
60
61             // the follow makes it display from left to right to allow
62             // horizontal scrolling to work
63             //verticalLayoutDirection: Grid.TopToBottom
64             //layoutDirection: Qt.LeftToRight
65             //flow: Grid.TopToBottom
66
67             // uncomment this out if you want to highlight the currently selected item
68             //highlight: Rectangle { width: 80; height: 80; color: "steelblue"; opacity: 0.3 }
69
70             model: ApplicationModel { id: applicationModel }
71             delegate: Item {
72                 width: grid.cellWidth
73                 height: grid.cellHeight
74
75                 Text {
76                     color: "white"
77                     anchors.top: myIcon.bottom
78                     anchors.left: parent.left
79                     anchors.right: parent.right
80                     anchors.margins: 20
81                     font.pixelSize: 25
82                     font.letterSpacing: 5
83                     wrapMode: Text.WordWrap
84                     horizontalAlignment: Text.AlignHCenter
85                     text: qsTr(model.name.toUpperCase())
86                 }
87
88                 Image {
89                     id: myIcon
90                     anchors.top: parent.top
91                     anchors.topMargin: 20
92                     anchors.horizontalCenter: parent.horizontalCenter
93                     // make the image/icons smaller than the grid cell size as
94                     // the text below/above current cell not be on top of the
95                     // current icon
96                     width: 220
97                     height: 220
98                     source: model.icon
99                     antialiasing: true
100                     property string initial: model.name.substring(0,1).toUpperCase()
101
102                     Item {
103                         id: title
104                         width: 125
105                         height: 125
106                         anchors.centerIn: parent
107                         Label {
108                             style: Text.Outline
109                             styleColor: '#00ADDC'
110                             color: 'transparent'
111                             font.pixelSize: 125
112                             anchors.centerIn: parent
113                             anchors.horizontalCenterOffset: model.index / 3 - 1
114                             anchors.verticalCenterOffset: model.index % 3 - 1
115                             text: model.icon === 'blank' ? myIcon.initial : ''
116                         }
117
118                         layer.enabled: true
119                         layer.effect: LinearGradient {
120                             gradient: Gradient {
121                                 GradientStop { position: -0.5; color: "#6BFBFF" }
122                                 GradientStop { position: +1.5; color: "#00ADDC" }
123                             }
124                         }
125                     }
126                 }
127
128                 MouseArea {
129                     id: loc
130                     anchors.fill: parent
131                     property string currentApp: ''
132                     onClicked: {
133                         parent.GridView.view.currentIndex = index
134                         currentApp = applicationModel.appid(parent.GridView.view.currentIndex)
135                         homescreenHandler.tapShortcut(currentApp)
136                     }
137                 }
138             }
139
140             Connections {
141                 target: homescreenHandler
142                 onAppListUpdate: {
143                     console.warn("applist update in Launcher.qml")
144                     applicationModel.updateApplist(info);
145                 }
146             }
147             Connections {
148                 target: homescreenHandler
149                 onInitAppList: {
150                     console.warn("applist init in Launcher.qml")
151                     applicationModel.initAppList(data);
152                 }
153             }
154         }
155     }
156 }