Revert "Use appid between homescreen-service and apps"
[apps/homescreen.git] / homescreen / qml / ShortcutArea.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
4  * Copyright (c) 2017 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
19 import QtQuick 2.2
20 import QtQuick.Layouts 1.1
21
22 Item {
23     id: root
24     width: 785
25     height: 218
26
27
28     ListModel {
29         id: applicationModel
30         ListElement {
31             name: 'launcher'
32             application: 'launcher@0.1'
33         }
34         ListElement {
35             name: 'MediaPlayer'
36             application: 'mediaplayer@0.1'
37         }
38         ListElement {
39             name: 'HVAC'
40             application: 'hvac@0.1'
41         }
42         ListElement {
43             name: 'Navigation'
44             application: 'navigation@0.1'
45         }
46     }
47
48     property int pid: -1
49
50     RowLayout {
51         anchors.fill: parent
52         spacing: 2
53         Repeater {
54             model: applicationModel
55             delegate: ShortcutIcon {
56                 Layout.fillWidth: true
57                 Layout.fillHeight: true
58                 name: model.name
59                 active: model.name === launcher.current
60                 onClicked: {
61                     pid = launcher.launch(model.application)
62                     if (1 < pid) {
63                         applicationArea.visible = true
64                     }
65                     else {
66                         console.warn(model.application)
67                         console.warn("app cannot be launched!")
68                     }
69                     homescreenHandler.tapShortcut(model.name)
70                 }
71             }
72         }
73     }
74 }