force display homescreen at startup
[staging/HomeScreen.git] / HomeScreen / qml / ShortcutArea.qml
1 /*
2  * Copyright (C) 2016 The Qt Company Ltd.
3  * Copyright (C) 2016 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.Layouts 1.1
20
21 Item {
22     id: root
23     width: 785
24     height: 218
25
26
27     ListModel {
28         id: applicationModel
29         ListElement {
30             name: 'Home'
31             application: 'home@0.1'
32             label: 'HOME'
33         }
34         ListElement {
35             name: 'Multimedia'
36             application: 'mediaplayer@0.1'
37             label: 'MULTIMEDIA'
38         }
39         ListElement {
40             name: 'HVAC'
41             application: 'hvac@0.1'
42             label: 'HVAC'
43         }
44         ListElement {
45             name: 'Navigation'
46             application: 'navigation@0.1'
47             label: 'NAVIGATION'
48         }
49     }
50     function languageChanged(lang) {
51         if(lang === "fr") {
52             applicationModel.setProperty(0, "label", 'ACCEUIL')
53             applicationModel.setProperty(1, "label", 'MULTIMÉDIA')
54             applicationModel.setProperty(2, "label", 'CLIMATISATION')
55             applicationModel.setProperty(3, "label", 'NAVIGATION')
56         } else {
57             applicationModel.setProperty(0, "label", 'HOME')
58             applicationModel.setProperty(1, "label", 'MULTIMEDIA')
59             applicationModel.setProperty(2, "label", 'HVAC')
60             applicationModel.setProperty(3, "label", 'NAVIGATION')
61         }
62     }
63
64     property int pid: -1
65
66     RowLayout {
67         anchors.fill: parent
68         spacing: 2
69         Repeater {
70             model: applicationModel
71             delegate: ShortcutIcon {
72                 Layout.fillWidth: true
73                 Layout.fillHeight: true
74                 name: model.name
75                 active: model.application === launcher.current
76                 onClicked: {
77                     if (0 === model.index) {
78                         appLauncherAreaLauncher.visible = true
79                         applicationArea.visible = false
80                         layoutHandler.hideAppLayer()
81                         launcher.current = ''
82                     }
83                     else {
84                         pid = launcher.launch(model.application)
85                         if (1 < pid) {
86                             applicationArea.visible = true
87                             appLauncherAreaLauncher.visible = false
88                             layoutHandler.makeMeVisible(pid)
89                             layoutHandler.showAppLayer(pid)
90                         }
91                         else {
92                             console.warn("app cannot be launched!")
93                         }
94                     }
95                 }
96             }
97         }
98     }
99     Component.onCompleted: {
100         root.currentIndex = 0
101         appLauncherAreaLauncher.visible = true
102         applicationArea.visible = false
103         layoutHandler.hideAppLayer()
104     }
105 }