Start app and get runnables list by homescreen
[apps/launcher.git] / launcher / qml / Launcher.qml
index ccca186..2247f51 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2016 The Qt Company Ltd.
  * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
- * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
+ * Copyright (c) 2018,2019 TOYOTA MOTOR CORPORATION
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,28 +21,30 @@ import QtQuick.Controls 2.0
 import AppModel 1.0
 
 ApplicationWindow {
-    id: root
-    // Layout.fillWidth: true
-    // Layout.fillHeight: true
-    // width: 1080
-    // Layout.preferredHeight: 1487
+    width: container.width * container.scale
+    height: container.height * container.scale
 
     property int pid: -1
-    Image {
-        y: 218
+
+    Item {
+        id: container
         anchors.centerIn: parent
-        source: './images/AGL_HMI_Blue_Background_Car-01.png'
-    }
+        width: 1080
+        height: 1488
+        scale: screenInfo.scale_factor()
 
+        Image {
+          anchors.centerIn: parent
+          source: './images/AGL_HMI_Blue_Background_Car-01.png'
+        }
 
     GridView {
         id: grid
-        x: 60
-        y: 100
-        width: 960
-        height: 1280
-        anchors.horizontalCenter: parent.horizontalCenter
-        anchors.verticalCenter: parent.verticalCenter
+        anchors {
+          topMargin: 60; bottomMargin: 0 
+          leftMargin: 60; rightMargin: 60
+          fill: parent
+        }
         contentHeight: 320
         flickableDirection: Flickable.AutoFlickDirection
         snapMode: GridView.SnapOneRow
@@ -57,6 +59,21 @@ ApplicationWindow {
             height: grid.cellHeight
         }
 
+        Connections {
+            target: homescreenHandler
+            onAppListUpdate: {
+                console.warn("applist update in Launcher.qml")
+                applicationModel.updateApplist(info);
+            }
+        }
+        Connections {
+            target: homescreenHandler
+            onInitAppList: {
+                console.warn("applist init in Launcher.qml")
+                applicationModel.initAppList(data);
+            }
+        }
+
         MouseArea {
             id: loc
             anchors.fill: parent
@@ -65,23 +82,16 @@ ApplicationWindow {
             property int index: grid.indexAt(loc.mouseX, loc.mouseY)
             x: 62
             y: 264
-            anchors.rightMargin: 0
-            anchors.bottomMargin: 0
-            anchors.leftMargin: 0
-            anchors.topMargin: 0
             onPressAndHold: currentId = applicationModel.id(newIndex = index)
             onReleased: {
+                if(loc.index < 0) {
+                    return
+                }
                 if (currentId === '') {
-                    pid = launcher.launch(applicationModel.id(loc.index))
-                    if (1 < pid) {
-                    }
-                    else {
-                        console.warn("app cannot be launched!")
-                    }
+                    homescreenHandler.tapShortcut(applicationModel.appid(loc.index))
                 } else {
                     currentId = ''
                 }
-                homescreenHandler.tapShortcut(applicationModel.name(loc.index))
             }
             onPositionChanged: {
                 if (loc.currentId === '') return
@@ -92,3 +102,4 @@ ApplicationWindow {
         }
     }
 }
+}